Base form control class.
Base form control class.
All form controls must extend this class.
Do not instantiate this class directly, use one of its descendants instead.
__construct($name) ¶Create a new form control instance.
If a subclass overrides the AnewtFormControl constructor, the parent constructor must be invoked as well.
$nameThe name of this control. It must be unique across this form.
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.
$valuesAn associative array from which the form control should be filled.
true if filling was succesfull, false otherwise.
get_id() ¶Return the form id.
This method falls back to the name value if no id was explicitly provided.
_set_form($form) [private] ¶Make the control reference its containing form.
$formA reference to an AnewtForm instance.
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.
True if empty, false otherwise.
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.
True if valid, false otherwise.
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.
$validatorA validator instance, e.g. AnewtValidatorLength or another AnewtValidator subclass.
$error_messageAn optional error message to be shown when this validator fails. Leave empty to not show an error.
build_widget() ¶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.
XHTML element with the minimal HTML markup needed for this control to function properly.
AnewtContainer::_to_array()AnewtContainer::_add()AnewtContainer::delete()AnewtContainer::get()AnewtContainer::_isset()AnewtContainer::_seed()AnewtContainer::setdefault()AnewtContainer::getdefault()AnewtContainer::set()AnewtContainer::__isset()AnewtContainer::__set()AnewtContainer::is_set()AnewtContainer::add()AnewtContainer::_getdefault()AnewtContainer::__unset()AnewtContainer::seed()AnewtContainer::to_array()AnewtContainer::_get()AnewtContainer::__get()AnewtContainer::keys()AnewtContainer::clear()AnewtContainer::_keys()AnewtContainer::_set()