laravel 5.4: From is gone. What is the new way to manipulate forms?

Question

Doing something in a blade with Form in a new laravel 5.4 project, e.g.

{{ Form::hidden('data-name', $value->name) }}

will throw:

Class 'Form' not found

There are many posts with ways to try to fix this (many different and conflicting answers, some with several files needing to be edited and commands run), but my question is what is the new "correct" way to manipulate the form in laravel 5.x, seeing as it has been dropped (and adding back is non trivial)?

Currently, I have resorted to this option for laravel 5+:

<input type="hidden" name="token" value="{{ app('request')->input('token') }}">

Show source
| laravel   | forms   2017-10-04 23:10 2 Answers

Answers to laravel 5.4: From is gone. What is the new way to manipulate forms? ( 2 )

  1. 2017-10-05 00:10

    Laravel externalized the management of Forms, Here is the package that implements it the way it used to be ( {{ Form::open() }} ), ( {{ Form::close() }} ) etc. All the fields are in the documentation.

  2. 2017-10-05 13:10

    Run the following command

    composer require "laravelcollective/html":"^5.4.0"
    

    Next, add your new provider to the providers array of config/app.php:

      'providers' => [
        // ...
        Collective\Html\HtmlServiceProvider::class,
        // ...
      ],
    

    Finally, add two class aliases to the aliases array of config/app.php:

      'aliases' => [
        // ...
          'Form' => Collective\Html\FormFacade::class,
          'Html' => Collective\Html\HtmlFacade::class,
        // ...
      ],
    

Leave a reply to - laravel 5.4: From is gone. What is the new way to manipulate forms?

◀ Go back