Pluf_Form_Field Class Reference

Inheritance diagram for Pluf_Form_Field:

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 Pluf_Form_Field_Varchar

List of all members.

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())


Detailed Description

Default form field.

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.


Constructor & Destructor Documentation

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?'));

Parameters:
array Params of the field.


Member Function Documentation

Pluf_Form_Field::clean ( value  ) 

Validate some possible input for the field.

Parameters:
mixed Value to clean.
Returns:
mixed Cleaned data or throw a Pluf_Form_Invalid exception.

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.

Parameters:
mixed Value
Returns:
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.

See also:
Pluf_Form_Field_Integer::clean
Parameters:
array Values
Returns:
array Values

Pluf_Form_Field::widgetAttrs ( widget  ) 

Returns the HTML attributes to add to the field.

Parameters:
object Widget
Returns:
array HTML attributes.

Reimplemented in Pluf_Form_Field_Varchar.


Member Data Documentation

Pluf_Form_Field::$class = 'Pluf_Form_Field'

Store the name of the class.

Pluf_Form_Field::$widget = 'Pluf_Form_Widget_TextInput'

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]


The documentation for this class was generated from the following file:

Generated on Wed Feb 3 15:44:52 2010 for Pluf by  doxygen