depage-forms v1.4.1
html forms made easy
Loading...
Searching...
No Matches
Multiple Class Reference

HTML-multiple-choice input type i.e. More...

Detailed Description

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:124

Definition at line 59 of file Multiple.php.

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Additional Inherited Members

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

Constructor & Destructor Documentation

◆ __construct()

__construct ( string $name,
array $parameters,
object $form )
Parameters
string$nameelement name
array$parameterselement parameters, HTML attributes, validator specs etc.
object$formparent form object

Reimplemented from Input.

Definition at line 92 of file Multiple.php.

Member Function Documentation

◆ __toString()

__toString ( )
Returns
string HTML rendered element
See also
htmlList()

Definition at line 183 of file Multiple.php.

◆ htmlInputAttributes()

htmlInputAttributes ( )
protected

(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 224 of file Multiple.php.

◆ htmlList()

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

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 133 of file Multiple.php.

◆ setDefaults()

setDefaults ( )
protected

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 110 of file Multiple.php.

◆ typeCastValue()

typeCastValue ( )
protected
Returns
void

Reimplemented from Input.

Definition at line 243 of file Multiple.php.

Field Documentation

◆ $list

$list = []
protected

Definition at line 64 of file Multiple.php.

◆ $listHtml

$listHtml = []
protected

This is used for custom html inside of options. Indexes have to be the same as in $list. This also only works with radio and checkbox skins.

Definition at line 73 of file Multiple.php.

◆ $maxItems

$maxItems = null
protected

Definition at line 83 of file Multiple.php.

◆ $skin

$skin = 'radio'
protected

Definition at line 78 of file Multiple.php.


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