Form - Validating and saving


Automatic validation

Form entries can be validated automatically based on their type.

[todo: this is unsupported and needs more documentation!]

Validation based on regex

For custom data you can add regular expressions in the admin interface which will be used to validate it. Make sure to test the regex in the admin against a few common entries before you save it.

[todo: this is unsupported and needs more documentation!]

Custom validation action

You can set up a custom validation action which will allow you to perform all sorts of additional validations. This is often necessary when you want to validate a combination of multiple fields, for example to check duplication based on several different entries.

The custom logic should be placed in form/default.ctl.php / __validate(). It will receive the current Form object as the first parameter and the currently sent data as a key/value array in the second.

Here’s a short example:

Custom save action

Much like the custom validation action above, you can also customize what happens when the form is saved. You can use this for example to create a User registration or other custom app logic when a Form> is sent.

This method will only be called after the form entry was successfully validated and saved!

The custom logic should be placed in form/default.ctl.php / __afterSave(). It will receive the current FormEntry object as the first and only parameter.

See __afterSave in the example code above!

Outlast Web & Mobile Development (c) 2023 | Privacy Policy |