Active form will create set of inputs based on model definition. This includes labels, validation, help messages, and any other information which could be included in form.
Creating form is minimized to just placing inputs whether designer want's, without need to know any details about fields - just it's names. This approach allow to split responsibilities, so that developer can focus on proper data handling, while designer can easy arrange layout.
To create set of inputs, designer need to have model instance and need to know which fields are about to be created. That's it. Let's create a simple form:
$form = ActiveForm::widget([ 'model' => new ExampleUser ]); echo $form; // Open form input echo $form->renderFields('username', 'email', 'about'); // Render fields echo $form->close(); // Close form
In just a few lines, form with labels, validation, hint etc. was created. All of these additional informations are provided in model class.
Here, we use model provided with this package, it has defined some properties.
username field has several validators, and label. These are defined
/** * @Label('Username') * * @RequiredValidator * @Decorator(Action, 'app.module.uac.user.view', 'username') * * @see UserNameValidator * @see Link * @see Action * @var string */ public $username;