Form methods
Mandatory methods
mount_form
If the form type requires it, pass a $model
instance to the form in mount()
See Model Binding page.
fields
Where you define the form fields.
Optional methods
formAttr
Form defaults reside in tall-form config file, override them with the formAttr()
method. See Form Buttons or Form slots for more examples.
beforeFormProperties
Executes before form_data is set. Example:
afterFormProperties
Executes after form_data is set. See another example at the end of this page.
resetFormData = Reset button
If you want to override the default reset form method. You can call this method to reset the form, in any another method
Default:
render
This method renders the form component view, you don't need to add it to the component.
If you have to override it, make sure to return $this->formView()
.
Example:
autoSelectSingleArrayValue
Auto populate a field with an option if there is only one value available. Initially developed for BelongsTo
relationships where a query might return only one model, but can be used for any field as a conditional value.
$arrayName
= Flatarray
askey => value
. IMPORTANT: Please note that the method only works with a key/value array. It extracts the value, with php array_values(), and uses it to populate the field.$field
= String. The name of the field that should be auto populated.IMPORTANT NOTE: This method can only be called after
form_data
is set, like in theafterFormProperties()
method.
Example: If there is only one item in the users array, the user_id field will be auto populated.
Last updated
Was this helpful?