Detailed Description

HTML number input type.

Class for HTML5 input type "number".

Usage

<?php
$form = new depage\htmlform\htmlform('myform');
// add a number field
$form->addNumber('any', array(
'label' => 'Any number',
));
// add a number field with restrictions
$form->addNumber('even', array(
'label' => 'Even number between 0 and 10, inclusive',
'min' => 0,
'max' => 10,
'step' => 2,
));
// process form
$form->process();
// Display the form.
echo ($form);

Definition at line 44 of file elements/number.php.

Inheritance diagram for number:

Public Member Functions

 __toString ()
 Renders element to HTML. More...
 
 isEmpty ()
 custom empty check More...
 
- Public Member Functions inherited from text
 __construct ($name, $parameters, $form)
 text 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...
 
 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...
 
 getLabel ()
 Returns the current input elements' label. More...
 
 clearValue ()
 resets the value to null More...
 
 setDefaultValue ($newDefaultValue)
 set 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...
 
 setDisabled ($disabled=true)
 Sets the HTML disabled-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...
 
 clearValue ()
 resets the value to null More...
 
 getName ()
 Returns the element name. More...
 

Protected Member Functions

 setDefaults ()
 collects initial values across subclasses. More...
 
 htmlMin ()
 Renders HTML min attribute. More...
 
 htmlMax ()
 Renders HTML max attribute. More...
 
 htmlStep ()
 Renders HTML step attribute. More...
 
 validatorCall ()
 custom validator call More...
 
 typeCastValue ()
 Converts value to element specific type. More...
 
- Protected Member Functions inherited from text
 setDefaults ()
 collects initial values across subclasses More...
 
 htmlList ($options=null)
 Renders HTML datalist. More...
 
 htmlInputAttributes ()
 renders text element specific HTML attributes 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...
 
 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...
 

Protected Attributes

 $min
 Minimum range HTML attribute. More...
 
 $max
 Maximum range HTML attribute. More...
 
 $step
 Step HTML attribute. More...
 
- Protected Attributes inherited from text
 $placeholder
 HTML placeholder attribute. 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...
 
 $formName
 Name of the parent HTML form. Used to identify the element once it's rendered. 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 hep 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 element
 $valid
 Contains element validation status/result. More...
 

Member Function Documentation

__toString ( )

Renders element to HTML.

Returns
string HTML rendered element

Definition at line 84 of file elements/number.php.

htmlMax ( )
protected

Renders HTML max attribute.

Returns
string HTML max attribute

Definition at line 124 of file elements/number.php.

htmlMin ( )
protected

Renders HTML min attribute.

Returns
string HTML min attribute

Definition at line 114 of file elements/number.php.

htmlStep ( )
protected

Renders HTML step attribute.

Returns
string HTML step attribute

Definition at line 134 of file elements/number.php.

isEmpty ( )

custom empty check

Number specific empty check (allows for zero int/float values)

Returns
bool empty-check result

Definition at line 205 of file elements/number.php.

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

Definition at line 68 of file elements/number.php.

typeCastValue ( )
protected

Converts value to element specific type.

Based on (parseFloat) http://www.php.net/manual/en/function.floatval.php#84793

Returns
void

Definition at line 163 of file elements/number.php.

validatorCall ( )
protected

custom validator call

Number specific validator call (includes min and max values)

Returns
bool validaton result

Definition at line 146 of file elements/number.php.

Field Documentation

$max
protected

Maximum range HTML attribute.

Definition at line 53 of file elements/number.php.

$min
protected

Minimum range HTML attribute.

Definition at line 49 of file elements/number.php.

$step
protected

Step HTML attribute.

Definition at line 57 of file elements/number.php.


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