spunQ_SingleChoiceField Class Reference

Allows choosing one from predefined options. More...

Inheritance diagram for spunQ_SingleChoiceField:

spunQ_ChoiceField spunQ_IFieldValueConverter spunQ_IField

List of all members.

Public Member Functions

 __construct (spunQ_IFieldContainer $container, $name)
 Constructor.
 getDefaultTemplate ()
 _processSubmission (&$rawValue)
 Initializes this field's submitted values.
 convertSpunQToRaw ($value)
 Converts an application value to a raw value.
 convertRawToSpunQ ($messagePrefix, &$value)
 Converts a raw value to an application value.
 setOptions (array $options)
 Set available options.
 addOption ($option, $key=NULL)
 Adds another option.
 getOptions ()
 Provides available options.
 setUseSubmittedValue ($useSubmittedValue=true)
 Sets the return value of getUseSubmittedValue().
 getForm ()
 Provides the form this field resides in.
 __clone ()
 Called after this object was cloned (on the newly created object).
 getContainer ()
 setContainer (spunQ_IFieldContainer $container)
 getName ()
 getTypePath ()
 getTypePathPart ()
 addConverter (spunQ_IFieldValueConverter $converter)
 addValidator (spunQ_IFieldValidator $validator)
 getConverters ()
 getValidators ()
 getHtmlId ($postfix= '')
 getHtmlName ()
 getUseSubmittedValue ()
 show ($value=NULL, $template=NULL, $templateParameters=array(), $htmlIdPostFix= '')
 showValidatorsJs ()
 submittedValueValid ()
 getSubmittedRawValue ()
 getSubmittedValue ()
 getValue ()
 getDisplayValue ($originalValue)
 getValidationMessages ()
 getFieldByPath ($path)

Static Public Member Functions

static normalizeTemplateCssParameter ($class)
 Normalizes the $class parameter passed to a field template.

Protected Member Functions

 spunQToRaw ($value)
 Will convert a spunQ value to a raw value using registered converters.
 rawToSpunQ (&$value)
 Partial implementation of _processSubmission().

Protected Attributes

 $options = array()
 Available options.
 $name
 Name of this field.
 $container
 The container this field is residing in.
 $useSubmittedValue = true
 Whether the submitted value should override the default value.
 $converters = array()
 The converters that have been registered with this field.
 $validators = array()
 Registered field validators.
 $validationMessages = NULL
 Messages generated by validators and converters.
 $submittedValue = NULL
 Value that was submitted for this field.
 $submittedRawValue = NULL
 Raw value that was submitted for this field.


Detailed Description

Allows choosing one from predefined options.

Definition at line 6 of file SingleChoiceField.class.php.


Member Function Documentation

spunQ_Field::__clone (  )  [inherited]

Called after this object was cloned (on the newly created object).

Will unset its container, so setContainer() must be called on cloned spunQ_Fields.

Returns:
void

Definition at line 133 of file Field.class.php.

spunQ_SingleChoiceField::_processSubmission ( &$  value  ) 

Initializes this field's submitted values.

Intended to be called by this field's container.

Parameters:
$value The raw value that was submitted for this field. The field is expected to return the processed value via this in/out parameter.
Returns:
boolean Whether the submitted value was valid.

Implements spunQ_IField.

Definition at line 31 of file SingleChoiceField.class.php.

spunQ_ChoiceField::addOption ( option,
key = NULL 
) [inherited]

Adds another option.

Parameters:
$option A new option the user may choose.
$key Additional parameter that may be provided. If it is present, this will be the raw value of this option. Otherwise the option will receive a random numeric raw value.
Returns:
spunQ_ChoiceField $this

Definition at line 35 of file ChoiceField.class.php.

spunQ_SingleChoiceField::convertRawToSpunQ ( messagePrefix,
&$  value 
)

Converts a raw value to an application value.

Parameters:
$messagePrefix String to be prefixed to translation key of validation messages.
$value The value to convert. This is also an out parameter that will contain the converted spunQ value.
Returns:
array<string> Validation messages for the value.
Exceptions:
spunQ_InvalidRawValueException If the raw value has an unexpected type (i.e. array instead of string or vice versa.)

Implements spunQ_IFieldValueConverter.

Definition at line 57 of file SingleChoiceField.class.php.

spunQ_SingleChoiceField::convertSpunQToRaw ( value  ) 

Converts an application value to a raw value.

Parameters:
$value The value to convert.
Returns:
any The converted value.

Implements spunQ_IFieldValueConverter.

Definition at line 41 of file SingleChoiceField.class.php.

spunQ_Field::getForm (  )  [inherited]

Provides the form this field resides in.

Returns:
spunQ_Form

Definition at line 120 of file Field.class.php.

spunQ_ChoiceField::getOptions (  )  [inherited]

Provides available options.

Returns:
array<any>

Definition at line 48 of file ChoiceField.class.php.

static spunQ_Field::normalizeTemplateCssParameter ( class  )  [static, inherited]

Normalizes the $class parameter passed to a field template.

Many field templates have an optional parameter called $class that can be passed either of the following:

  • a string containing css classes
  • an array containing strings as css classes
  • NULL indicating, that no class declaration is to be added.
Parameters:
$class The value that was passed to the template. Either of the types mentioned in the function description.
Returns:
A css string that can be safely inserted into the class attribute of an html node.
Exceptions:
spunQ_HtmlException If the parameter has an unexpected type or an invalid css declaration.

Definition at line 20 of file Field.class.php.

spunQ_Field::rawToSpunQ ( &$  value  )  [protected, inherited]

Partial implementation of _processSubmission().

See also:
_processSubmission()
Parameters:
$value Same as for _processSubmission().
Returns:
boolean

Definition at line 366 of file Field.class.php.

spunQ_ChoiceField::setOptions ( array $  options  )  [inherited]

Set available options.

Type:
$options The options the user may choose from.
Returns:
spunQ_ChoiceField $this

Definition at line 19 of file ChoiceField.class.php.

spunQ_Field::setUseSubmittedValue ( useSubmittedValue = true  )  [inherited]

Sets the return value of getUseSubmittedValue().

Parameters:
$useSubmittedValue The new value for getUseSubmittedValue()
Returns:
spunQ_Field $this

Definition at line 111 of file Field.class.php.

spunQ_Field::spunQToRaw ( value  )  [protected, inherited]

Will convert a spunQ value to a raw value using registered converters.

See also:
spunQ_IFieldValueConverter
Parameters:
$value The value to convert
Returns:
any The converted value.

Definition at line 353 of file Field.class.php.


Member Data Documentation

spunQ_Field::$container [protected, inherited]

The container this field is residing in.

Type:
spunQ_IFieldContainer

Definition at line 48 of file Field.class.php.

spunQ_Field::$converters = array() [protected, inherited]

The converters that have been registered with this field.

Type:
array<spunQ_IFieldValueConverter>

Definition at line 63 of file Field.class.php.

spunQ_Field::$name [protected, inherited]

Name of this field.

Type:
string

Definition at line 42 of file Field.class.php.

spunQ_ChoiceField::$options = array() [protected, inherited]

Available options.

Type:
array<any>

Definition at line 12 of file ChoiceField.class.php.

spunQ_Field::$submittedRawValue = NULL [protected, inherited]

Raw value that was submitted for this field.

Type:
any

Definition at line 89 of file Field.class.php.

spunQ_Field::$submittedValue = NULL [protected, inherited]

Value that was submitted for this field.

Initialized in _processSubmission().

Type:
any

Definition at line 83 of file Field.class.php.

spunQ_Field::$useSubmittedValue = true [protected, inherited]

Whether the submitted value should override the default value.

In other words: If this is set to true, the field will display the value that was submitted previously instead of the default value.

See also:
spunQ_IField::getUseSubmittedValue()
Type:
boolean

Definition at line 57 of file Field.class.php.

spunQ_Field::$validationMessages = NULL [protected, inherited]

Messages generated by validators and converters.

Initialized in _processSubmission().

Type:
array<string>

Definition at line 76 of file Field.class.php.

spunQ_Field::$validators = array() [protected, inherited]

Registered field validators.

Type:
array<spunQ_IFieldValidator>

Definition at line 69 of file Field.class.php.


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

Generated on Fri Jul 1 11:12:43 2011 for spunQ3 by  doxygen 1.5.9