Public Member Functions | |
| __construct ($name) | |
| Create a new form control instance. | |
Validation methods | |
| is_empty () | |
| Check whether this control is to be considered 'empty'. | |
| is_valid () | |
| Check whether this form control is valid. | |
| add_validator ($validator, $error_message=null) | |
| Add a validator instance to this form control. | |
Rendering methods | |
| build_widget () | |
| Render the minimal HTML needed for this control to work. | |
Protected Attributes | |
| $_form | |
| Reference to containing AnewtForm instance. | |
| $_validators | |
| List of validators. | |
| $_validator_errors | |
| List of validator error messages. | |
Getter and setter methods | |
| fill ($values) | |
| Fill the form control from the given values. | |
| get_id () | |
| Return the form id. | |
| _set_form ($form) | |
| Make the control reference its containing form. | |
All form controls must extend this class.
Do not instantiate this class directly, use one of its descendants instead.
Definition at line 18 of file form/controls/base.lib.php.
| AnewtFormControl::__construct | ( | $ | name | ) |
Create a new form control instance.
If a subclass overrides the AnewtFormControl constructor, the parent constructor must be invoked as well.
| $name | The name of this control. It must be unique across this form. |
Reimplemented from AnewtContainer.
Reimplemented in AnewtFormControlButton, AnewtFormControlButtonSubmit, AnewtFormControlButtonReset, AnewtFormControlCheckbox, AnewtFormControlChoice, AnewtFormControlTextBase, AnewtFormControlText, AnewtFormControlPassword, and AnewtFormControlTextMultiline.
Definition at line 50 of file form/controls/base.lib.php.
| AnewtFormControl::fill | ( | $ | values | ) |
Fill the form control from the given values.
This only sets the value for controls for which the can-be-filled property is enabled.
The return value of this function indicates whether the control was successfully filled with a value. For some control types such as checkboxes this always succeeds since both presence and absence of the value from $values are meaningful. For other controls such as text inputs this is only true if the value was actually present in the $values parameters.
| $values | An associative array from which the form control should be filled. |
true if filling was succesfull, false otherwise.Reimplemented in AnewtFormControlButtonSubmit, AnewtFormControlCheckbox, AnewtFormControlChoice, and AnewtFormControlFileUpload.
Definition at line 116 of file form/controls/base.lib.php.
| AnewtFormControl::get_id | ( | ) |
Return the form id.
This method falls back to the name value if no id was explicitly provided.
Definition at line 140 of file form/controls/base.lib.php.
| AnewtFormControl::_set_form | ( | $ | form | ) | [private] |
Make the control reference its containing form.
| $form | A reference to an AnewtForm instance. |
Definition at line 157 of file form/controls/base.lib.php.
| AnewtFormControl::is_empty | ( | ) |
Check whether this control is to be considered 'empty'.
This method is invoked when validating a form. When a control is optional and empty, no validators are applied to it. The base implementation just checks whether the value property is an empty string, but subclasses may do more sensible checks.
Definition at line 181 of file form/controls/base.lib.php.
| AnewtFormControl::is_valid | ( | ) |
Check whether this form control is valid.
The default is to apply all validators added to this control. Subclasses could also override this method to do something more sensible than applying validators, since some controls don't accept validators, e.g. checkboxes.
Reimplemented in AnewtFormControlChoice, AnewtFormControlFileUpload, and AnewtFormControlTextBase.
Definition at line 196 of file form/controls/base.lib.php.
| AnewtFormControl::add_validator | ( | $ | validator, | |
| $ | error_message = null | |||
| ) |
Add a validator instance to this form control.
The (optional) error message will be shown when the validator fails to validate the form control.
| $validator | A validator instance, e.g. AnewtValidatorLength or another AnewtValidator subclass. | |
| $error_message | An optional error message to be shown when this validator fails. Leave empty to not show an error. |
Definition at line 232 of file form/controls/base.lib.php.
| AnewtFormControl::build_widget | ( | ) | [abstract] |
Render the minimal HTML needed for this control to work.
Form control implementations should implement this method, e.g. for a checkbox a simple input HTML element should be returned.
Reimplemented in AnewtFormControlButton, AnewtFormControlCheckbox, AnewtFormControlChoice, AnewtFormControlFileUpload, AnewtFormControlTextBase, and AnewtFormControlHidden.
AnewtFormControl::$_form [protected] |
Reference to containing AnewtForm instance.
Definition at line 25 of file form/controls/base.lib.php.
AnewtFormControl::$_validators [protected] |
List of validators.
Definition at line 32 of file form/controls/base.lib.php.
AnewtFormControl::$_validator_errors [protected] |
List of validator error messages.
Definition at line 39 of file form/controls/base.lib.php.
1.5.9