Multiple Class Reference

Detailed Description

HTML-multiple-choice input type i.e.

checkbox and select.

Class for multiple-choice type HTML elements. Has the same return value, regardless of skin type (checkbox or select).

See also
Depage::HtmlForm::Elements::Single
Depage::HtmlForm::Elements::Boolean

Usage

<?php
$form = new Depage\HtmlForm\HtmlForm('myform');
// add multiple-element (checkbox is the default skin)
$form->addMultiple('listOne', array(
'label' => 'Spoken languages',
'list' => array(
'en' => 'English',
'es' => 'Spanish',
'fr' => 'French',
),
));
// add a multiple-element with select-skin
$form->addMultiple('listTwo', array(
'label' => 'Spoken languages',
'skin' => 'select',
'list' => array(
'en' => 'English',
'es' => 'Spanish',
'fr' => 'French',
),
));
// process form
$form->process();
// Display the form.
echo ($form);
main interface to users
Definition: HtmlForm.php:120

Definition at line 58 of file Multiple.php.

Public Member Functions

 __construct ($name, $parameters, $form)
 multiple class constructor More...
 
 __toString ()
 Renders element to HTML. More...
 
- Public Member Functions inherited from Input
 __construct ($name, $parameters, $form)
 input class constructor More...
 
 validate ()
 Validates input element. More...
 
 invalidate ()
 Invalidates input. More...
 
 isEmpty ()
 says wether the element value is empty More...
 
 setValue ($newValue)
 set the input element value More...
 
 getValue ()
 Returns the current input elements' value. More...
 
 setLabel ($label)
 set the label of the input More...
 
 getLabel ()
 Returns the current input elements' label. More...
 
 setErrorMessage ($message)
 setErrorMessage More...
 
 getErrorMessage ()
 getErrorMessage More...
 
 clearValue ()
 resets the value to null More...
 
 setDefaultValue ($newDefaultValue)
 set the initial input element value More...
 
 getDefaultValue ()
 gets the initial input element value More...
 
 setAutofocus ($autofocus=true)
 Sets the HTML autofocus-attribute of the current input element. More...
 
 setRequired ($required=true)
 Sets the HTML required-attribute of the current input element. More...
 
- Public Member Functions inherited from Element
 __construct ($name, $parameters, $form)
 element class constructor More...
 
 __call ($function, $arguments)
 HTML escaping. More...
 
 setDisabled ($disabled=true)
 Sets the HTML disabled-attribute of the current input element. More...
 
 getDisabled ()
 Gets if input is currently disabled. More...
 
 clearValue ()
 resets the value to null More...
 
 getName ()
 Returns the element name. More...
 

Protected Member Functions

 setDefaults ()
 collects initial values across subclasses. More...
 
 htmlList ($options=null, $value=null)
 HTML option list rendering. More...
 
 htmlInputAttributes ()
 Returns string of HTML attributes for input element. More...
 
 typeCastValue ()
 Converts value to element specific type. More...
 
- Protected Member Functions inherited from Input
 setDefaults ()
 Sets the default values for input elements. More...
 
 validatorCall ()
 custom validator call hook More...
 
 typeCastValue ()
 converts element value More...
 
 htmlClasses ()
 Returns string of the elements' HTML-classes, separated by spaces. More...
 
 htmlMarker ()
 Returns elements' required-indicator. More...
 
 htmlInputAttributes ()
 Returns string of HTML attributes for input element. More...
 
 htmlDataAttributes ()
 Returns dataAttr escaped as attribute string. More...
 
 htmlWrapperAttributes ()
 Returns string of HTML attributes for element wrapper paragraph. More...
 
 htmlValue ()
 Returns HTML-rendered element value. More...
 
 htmlErrorMessage ()
 Returns HTML-rendered error message. More...
 
 htmlHelpMessage ()
 Returns HTML-rendered helpMessage. More...
 
- Protected Member Functions inherited from Element
 setDefaults ()
 Collects initial values across subclasses. More...
 
 checkParameters ($parameters)
 checks element parameters More...
 
 log ($argument, $type=null)
 error & warning logger More...
 
 htmlEscape ($options=array())
 Escapes HTML in strings and arrays of strings. More...
 
 htmlDataAttributes ()
 Returns dataAttr escaped as attribute string. More...
 

Protected Attributes

 $list = array()
 Contains list of selectable options. More...
 
 $maxItems = null
 maxItems More...
 
- Protected Attributes inherited from Input
 $type
 Input element type - HTML input type attribute. More...
 
 $label
 Input element - HTML label. More...
 
 $marker
 Input element - HTML marker text that marks required fields. More...
 
 $required
 True if the input element is required to hold a value to be valid. More...
 
 $disabled
 wether a input element will be disabled More...
 
 $readonly
 wether a input element will be readonly More...
 
 $formName
 Name of the parent HTML form. More...
 
 $value = null
 Input elements's value. More...
 
 $validator
 Holds validator object reference. More...
 
 $class
 class for paragraph More...
 
 $classes
 HTML classes attribute for rendering the input element. More...
 
 $autofocus = false
 HTML autofocus attribute. More...
 
 $autocapitalize
 HTML autocapitalize attribute. More...
 
 $autocorrect
 HTML autocorrect attribute. More...
 
 $autocomplete
 HTML autocomplete attribute. More...
 
 $pattern
 HTML pattern attribute. More...
 
 $errorMessage
 Message that gets displayed in case of invalid input. More...
 
 $helpMessage
 Extra help message. More...
 
 $helpMessageHtml
 Extra help message in html format. More...
 
- Protected Attributes inherited from Element
 $name
 Element name. More...
 
 $validated = false
 True if the element has been validated before. More...
 
 $log
 Log object reference. More...
 

Additional Inherited Members

- Data Fields inherited from Input
 $dataPath
 Extra information about the data that is saved inside the element. More...
 
- Data Fields inherited from Element
 $valid
 Contains element validation status/result. More...
 
 $dataAttr
 Extra information about the data that is saved inside the element. More...
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $name,
  $parameters,
  $form 
)

multiple class constructor

Parameters
string$nameelement name
array$parameterselement parameters, HTML attributes, validator specs etc.
object$formparent form object
Returns
void

Reimplemented from Input.

Definition at line 78 of file Multiple.php.

Member Function Documentation

◆ __toString()

__toString ( )

Renders element to HTML.

Returns
string HTML rendered element
See also
htmlList()

Definition at line 162 of file Multiple.php.

◆ htmlInputAttributes()

htmlInputAttributes ( )
protected

Returns string of HTML attributes for input element.

(overrides parent to avoid awkward HTML5 checkbox validation (all boxes need to be checked if required))

Returns
string $attributes HTML attributes

Reimplemented from Input.

Definition at line 203 of file Multiple.php.

◆ htmlList()

htmlList (   $options = null,
  $value = null 
)
protected

HTML option list rendering.

Renders HTML - option list part of select/checkbox element. Works recursively in case of select-optgroups. If no parameters are parsed, it uses the list attribute of this element.

Parameters
array$optionslist elements and subgroups
array$valuevalues to be marked as selected
Returns
string $list rendered options-part of the HTML-select-element
See also
__toString()

Definition at line 118 of file Multiple.php.

◆ setDefaults()

setDefaults ( )
protected

collects initial values across subclasses.

The constructor loops through these and creates settable class attributes at runtime. It's a compact mechanism for initialising a lot of variables.

Returns
void

Reimplemented from Input.

Definition at line 95 of file Multiple.php.

◆ typeCastValue()

typeCastValue ( )
protected

Converts value to element specific type.

Returns
void

Reimplemented from Input.

Definition at line 218 of file Multiple.php.

Field Documentation

◆ $list

$list = array()
protected

Contains list of selectable options.

Definition at line 63 of file Multiple.php.

◆ $maxItems

$maxItems = null
protected

maxItems

Definition at line 68 of file Multiple.php.


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