Maslosoft Framework Logo Maslosoft Framework Documentation
Flexible Application Foundation

Active Form

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.

Forms capabilities can be extended with plugins enchanced with decorators, new input types can be created using special plugin type - renderer.

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:


Write something about You

$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. For instance, username field has several validators, and label. These are defined by annotations:

     * @Label('Username')
     * @RequiredValidator
     * @Decorator(Action, 'app.module.uac.user.view', 'username')
     * @see UserNameValidator
     * @see Link
     * @see Action
     * @var string
public $username;

See also