\Pluf_Form_Field_Slug

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.

Summary

Methods
Properties
Constants
__construct()
clean()
setDefaultEmpty()
multiClean()
widgetAttrs()
$class
$widget
$label
$required
$help_text
$initial
$choices
$hidden_widget
$value
$multiple
$min_size
$max_size
No constants found
No protected methods found
$empty_values
$_error_messages
N/A
No private methods found
No private properties found
N/A

Properties

$class

$class : 

Store the name of the class.

Type

$widget

$widget : string

Name of the widget to use for build the forms.

The way to "present" the field to the user.

Type

string

$label

$label : 

Type

$required

$required : 

< The label of the field.

Type

$help_text

$help_text : 

< Allowed to be blank.

Type

$initial

$initial : 

< Help text for the field.

Type

$choices

$choices : 

< Default value when empty.

Type

$hidden_widget

$hidden_widget : 

Type

$value

$value : 

Type

$multiple

$multiple : 

Returning multiple values (select multiple etc.)

Type

$min_size

$min_size : integer

Minimum size of field.

Default to 1.

Type

integer

$max_size

$max_size : integer

Maximum size of field.

Default to 50.

Type

integer

$empty_values

$empty_values : 

Type

$_error_messages

$_error_messages : 

Type

Methods

__construct()

__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

$params

clean()

clean(  $value) : mixed

Removes any character not allowed and valid the size of the field.

Parameters

$value

Throws

\Pluf_Form_Invalid

If the lenght of the field has not a valid size.

Returns

mixed —

Cleaned data or throw a Pluf_Form_Invalid exception.

setDefaultEmpty()

setDefaultEmpty(  $value) : mixed

Set the default empty value for a field.

Parameters

$value

Returns

mixed —

Value

multiClean()

multiClean(  $value) : array

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.

Parameters

$value

Returns

array —

Values

widgetAttrs()

widgetAttrs(  $widget) : array

Returns the HTML attributes to add to the field.

Parameters

$widget

Returns

array —

HTML attributes.