Solar_Form::validate()

public bool Solar_Form::validate ( void )

Applies the filter chain to the form element values; in particular, checks validation and updates the 'invalid' keys for each element that fails, and checks for CSRF attempts automatically.

Parameters

  • None.

Returns

  • (bool) True if all elements are valid, false if not.

Description

Applies the filter chain to the form element values; in particular, checks validation and updates the 'invalid' keys for each element that fails, and checks for CSRF attempts automatically.

This method cycles through each element in the form, where it ...

  1. Applies the filters to populated user input for the element,

  2. Validates the filtered value against the validation rules for the element,

  3. Adds invalidation messages to the element if it does not pass validation.

If all populated values pass validation, the method returns boolean true, indicating the form as a whole it valid; if even one validation on one element fails, the method returns boolean false.

In general, you should only validate the values after user input has been populated with Solar_Form::populate().

Note that filters and validation rules are added with the Solar_Form::setElement() and Solar_Form::setElements() methods; please see those pages for more information on how to add filters and validation to an element.



Local