ksharifi said:
Use {{Form::open}} instead
I am using it, I just forgot to say that in my orginal post. it produces the same result, an empty hidden field. I'm not really sure what is going wrong with it.
CSRF token is stored in the session, check if the session store is well configured
The session is working fine with the database, but I also checked it with the session stored in a file and it doesn't work either way. I'm not really sure what to do, I can see the token in the session, but it will not display into the form unless I manually call csrf_token
I just did and the token works, now i need to figure out what I did to break it :/
I'm not sure what to do anymore, I disabled all packages and and tried reverting as much back to default and possible thinking that maybe it was a third part addon. Any ideas what could be causing this or how to rectify it?
Fixed it. I had form macro's in a file that I was including in bootstrap/start.php. It was causing the errror, as soon as I removed it the tokens started working perfectly.
I'm having this same issue with Laravel 4.2 (empty valued inputs for CSRF tokens when defining form macros in bootstrap/start.php), but I'd like to keep my macros.
I noticed this problem occurs because the definition of the macros force the FormBuilder to be created before the session is initialized, and since the session is not initialized until the $app->run() call in public/index.php I can't find the right place to define my form macros.
Are form macros and the CSRF filter exclusive?
Thanks.
Instead of using Form::macro I used HTML::macro, which I hadn't seen in the documentation. This was an option for my case, but I believe my last question still remains:
Does anybody know if form macros and the CSRF filter are exclusive/incompatible?
Thanks.
I had this issue on Laravel 5.2 and fixed it by placing my routes inside a "web" middleware group like this:
Route::group(['middleware' => ['web']], function () {
// Put your routes inside here
});
A complete explanation of what worked for me is at http://stackoverflow.com/questions/34422751/why-is-my-csrf-token-empty-when-using-formopen
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community