Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] explain setting form field default values #952

Merged
merged 2 commits into from
Feb 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ or you can tweak it when you create form like this::

$form = $app->add(['Form', 'buttonSave'=>[null, 'Subscribe', 'icon'=>'mail']]);

To set the default values in the fields of the form you can use the model property of the form.
Even if model not explicitly set (see section below) each form has an underlying model which is automatically generated::

// single field
$form->model->set('email', '[email protected]');

// or multiple fields
$form->model->set([
'name' => 'John',
'email' => '[email protected]'
]);

Form also relies on a ``atk4\ui\FormLayout`` class and displays fields through
decorators defined at ``atk4\ui\FormField``. See dedicated documentation for:

Expand Down