Just another questio, How to populate my own macros automatically with Form::model? Best regards
Yes I used It, but the problem only occurs when I included my own Macros
Happen to have the same problem. Using Laravel 5 and having the form macros in my routes.php file, which I required. Routes are working, but the value of the csrf input field is empty. When I delete the form macros everything is working again.
This is how you fix it. Macros must be loaded after HTMLServiceProvider, that is why csrf tokens are not generating. After this, just add the service provider to your config/app.php. You can remove HTMLServiceProvider from the list since we are loading it here.
<?php namespace App\Providers;
use Illuminate\Html\HtmlServiceProvider;
class MacroServiceProvider extends HtmlServiceProvider
{
/**
* Register the application services.
*
* @return void
*/
public function register()
{
// Macros must be loaded after the HTMLServiceProvider's
// register method is called. Otherwise, csrf tokens
// will not be generated
parent::register();
// Load macros
require base_path() . '/path/to/your//macros.php';
}
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community