
Public Member Functions | |
| __construct ($params=array()) | |
| clean ($value) | |
| setDefaultEmpty ($value) | |
| multiClean ($value) | |
| widgetAttrs ($widget) | |
Public Attributes | |
| $class = 'Pluf_Form_Field' | |
| $widget = 'Pluf_Form_Widget_TextInput' | |
| $label = '' | |
| $required = false | |
| $help_text = '' | |
| $initial = '' | |
| $choices = null | |
| $hidden_widget = 'Pluf_Form_Widget_HiddenInput' | |
| $value = '' | |
| $multiple = false | |
Protected Attributes | |
| $empty_values = array('', null, array()) | |
A form field is providing a defined set of methods and properties to be used in the rendering of the fields in forms, in the conversion of the data from the user input to a form usable by the models.
| Pluf_Form_Field::__construct | ( | $ | params = array() |
) |
Constructor.
Example: $field = new Your_Field(array('required'=>true, 'widget'=>'Pluf_Form_Widget_TextInput', 'initial'=>'your name here', 'label'=>__('Your name'), 'help_text'=>__('You are?'));
| array | Params of the field. |
| Pluf_Form_Field::clean | ( | $ | value | ) |
Validate some possible input for the field.
| mixed | Value to clean. |
Reimplemented in Pluf_Form_Field_Boolean, Pluf_Form_Field_Date, Pluf_Form_Field_Datetime, Pluf_Form_Field_Email, Pluf_Form_Field_File, Pluf_Form_Field_Float, Pluf_Form_Field_Integer, Pluf_Form_Field_ReCaptcha, Pluf_Form_Field_Url, and Pluf_Form_Field_Varchar.
| Pluf_Form_Field::setDefaultEmpty | ( | $ | value | ) |
Set the default empty value for a field.
| mixed | Value |
| Pluf_Form_Field::multiClean | ( | $ | value | ) |
Multi-clean a value.
If you are getting multiple values, you need to go through all of them and validate them against the requirements. This will do that for you. Basically, it is cloning the field, marking it as not multiple and validate each value. It will throw an exception in case of failure.
If you are implementing your own field which could be filled by a "multiple" widget, you need to perform a check on $this->multiple.
| array | Values |
| Pluf_Form_Field::widgetAttrs | ( | $ | widget | ) |
Returns the HTML attributes to add to the field.
| object | Widget |
Reimplemented in Pluf_Form_Field_Varchar.
| Pluf_Form_Field::$class = 'Pluf_Form_Field' |
Store the name of the class.
| Pluf_Form_Field::$widget = 'Pluf_Form_Widget_TextInput' |
Widget. The way to "present" the field to the user.
Reimplemented in Pluf_Form_Field_Boolean, Pluf_Form_Field_Date, Pluf_Form_Field_Datetime, Pluf_Form_Field_Email, Pluf_Form_Field_File, Pluf_Form_Field_Float, Pluf_Form_Field_Integer, Pluf_Form_Field_ReCaptcha, Pluf_Form_Field_Url, and Pluf_Form_Field_Varchar.
| Pluf_Form_Field::$label = '' |
The label of the field.
| Pluf_Form_Field::$required = false |
Allowed to be blank.
| Pluf_Form_Field::$help_text = '' |
Help text for the field.
| Pluf_Form_Field::$initial = '' |
Default value when empty.
| Pluf_Form_Field::$choices = null |
Predefined choices for the field.
| Pluf_Form_Field::$hidden_widget = 'Pluf_Form_Widget_HiddenInput' |
| Pluf_Form_Field::$value = '' |
Current value of the field.
| Pluf_Form_Field::$multiple = false |
Returning multiple values (select multiple etc.)
Pluf_Form_Field::$empty_values = array('', null, array()) [protected] |