Named form
Named form is basically a regular form with only one addition. It has name that is used to namespace fields in the form. There are 3 ways to set up a named form:
- Passing it as form option. This is recommended method
<?php
FormBuilder::create('App\Forms\LoginForm', [
'name' => 'users';
])
- Setting as property on the Form class. Useful when namespacing is always needed
<?php
Class LoginForm extends Form
{
protected $name = 'users';
}
- Using
setName
method on form class after instantiation. NOT RECOMMENDED
Avoid using this method because it requires rebuilding fields to set proper names.
<?php
FormBuilder::create('App\Forms\LoginForm')->setName('users');