JasonGenX
JasonGenX

Reputation: 5434

Laravel: Posting information with a form

I have something like this in my code:

<form class="form-horizontal" role="form" method="POST" action="{{url('/member/createMember')}}">
    <input type="hidden" name="_method" value="PUT">
    <input type="hidden" name="_token" value="{{ csrf_token() }}">
    <input type="hidden" name="invitation" value="{{ $invitation }}">
    <input type="hidden" name="partner" value="{{ $partner }}">

I would like to have $inviation, and $partner available to the /member/createMember function in the called controller.

Is there a more elegant way of achieving this other than hidden input elements? Isn't the content of the hidden fields communicated to the end user's browser anyway? Ideally I would like avoid involving the user's browser in this. Should I just retain the $partner and $invitation in the session?

Upvotes: 2

Views: 49

Answers (1)

Mrab Ezreb
Mrab Ezreb

Reputation: 440

I can think of two options:
Hidden Fields (what I personally use for things like this)
Session Storage (this might be a bit difficult, since you can set them (by echoing JS) but it is very hard to view them (unless JS does it))

Honestly, I can't think of much else, sorry about that! The user's browser really does need to be involved, since HTTP is stateless.

Upvotes: 1

Related Questions