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

container element base class More...

Detailed Description

The abstract container class contains the base for container type elements. ie. htmlform, fieldset and step

Magic Methods

The container class implements various magic methods to add new input elements

See also
Depage\HtmlForm\Elements
Magick Methods

Element addAddress($name, $parameters = array()) Adds a new address fieldset to the container.

Element addBoolean($name, $parameters = array()) Adds a new boolean input element to the container.

Element addButton($name, $parameters = array()) Adds a new button input element to the container.

Element addCaptcha($name, $parameters = array()) Adds a new captcha input element to the container.

Element addColor($name, $parameters = array()) Adds a new color input element to the container.

Element addCreditcard($name, $parameters = array()) Adds a new creditcard fieldset to the container.

Element addDate($name, $parameters = array()) Adds a new date input element to the container.

Element addDatetime($name, $parameters = array()) Adds a new datetime input element to the container.

Element addEmail($name, $parameters = array()) Adds a new email input element to the container.

Element addFieldset($name, $parameters = array()) Adds a new fieldset container to the container.

Element addFile($name, $parameters = array()) Adds a new file input element to the container.

Element addHidden($name, $parameters = array()) Adds a new hidden input element to the container.

Element addMonth($name, $parameters = array()) Adds a new month input element to the container.

Element addMultiple($name, $parameters = array()) Adds a new multiple

Element addNumber($name, $parameters = array()) Adds a new number input element to the container.

Element addPassword($name, $parameters = array()) Adds a new password

Element addPlaceholder($name, $parameters = array()) Adds a new placeholder input element to the container.

Element addPlaceholderMultiple($name, $parameters = array()) Adds a new multiple placeholder input element to the container

Element addRange($name, $parameters = array()) Adds a new range input element to the container.

Element addRichtext($name, $parameters = array()) Adds a new richtext input element to the container.

Element addSearch($name, $parameters = array()) Adds a new search input element to the container.

Element addSingle($name, $parameters = array()) Adds a new single choice input element to the container.

Element addState($name, $parameters = array()) Adds a new state input element to the container.

Element addStep($name, $parameters = array()) Adds a new step container

Element addTel($name, $parameters = array()) Adds a new telephone input element to the container.

Element addText($name, $parameters = array()) Adds a new text input element to the container.

Element addTextarea($name, $parameters = array()) Adds a new textarea input

Element addTime($name, $parameters = array()) Adds a new time input element to the container.

Element addUrl($name, $parameters = array()) Adds a new URL input element to the container.

Element addWeek($name, $parameters = array()) Adds a new week input element to the container.

Definition at line 59 of file Container.php.

Public Member Functions

 __construct (string $name, array $parameters, object $form)
 container class constructor
 __call (string $function, array $arguments)
 HTML escaping and add subelements.
 addChildElements ()
 Sub-element generator hook.
 getElements (bool $includeFieldsets=false)
 Returns containers subelements.
 getElement (string $name, bool $includeFieldsets=false)
 Gets subelement by name.
 addHtml (string $html)
 Adds a new custom HTML element to the container.
 addStepNav (array $parameter=[])
 Adds automatic step navigation to output.
 setRequired (bool $required=true)
 Sets required-attribute.
 validate ()
 Validates container and its contents.
 clearValue ()
 Deletes values of all child elements.
Public Member Functions inherited from Element
 __construct (string $name, array $parameters, object|null $form)
 element class constructor
 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

 addElement (string $type, string $name, array $parameters)
 Generates sub-elements.
Protected Member Functions inherited from Element
 setDefaults ()
 Collects initial values across subclasses.
 log (string $argument, string $type=null)
 error & warning logger
 htmlEscape (array|string $options=[])
 Escapes HTML in strings and arrays of strings.
 htmlDataAttributes ()
 Returns dataAttr escaped as attribute string.

Protected Attributes

 $elements = []
 References to input elements and fieldsets.
 $elementsAndHtml = []
 Input element, fieldset and custom HTML object references.
 $form
 Parent form object reference.
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 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$namecontainer name
array$parameterscontainer parameters, HTML attributes
object$formparent form object
Returns
void

Reimplemented in Address.

Definition at line 81 of file Container.php.

Member Function Documentation

◆ __call()

__call ( string $function,
array $arguments )
  1. (Methods beginning with "add") Calls addElement() with element-specific type argument. Tries to instantiate the respective class.
  2. (Methods beginnning with "html)" Returns the respective HTML escaped attributes for element rendering.
Parameters
string$functionfunction name
array$argumentsfunction arguments
Returns
object element object or (mixed) HTML escaped value
See also
addElement()
htmlEscape()

Reimplemented from Element.

Definition at line 104 of file Container.php.

◆ addChildElements()

addChildElements ( )

Adds child elements just after container construction. Can be used for subclasses of the container class to add new elements to itself.

(see Depage::HtmlForm::Elements::Creditcard for an example implementation)

Returns
void
See also
addElement()

Reimplemented in Address, and Creditcard.

Definition at line 165 of file Container.php.

◆ addElement()

addElement ( string $type,
string $name,
array $parameters )
protected

Adds new child elements to $this->elements.

Parameters
string$typeelememt type
string$nameelement name
array$parameterselement attributes: HTML attributes, validation parameters etc.
Returns
object $newElement new element object
See also
__call()
addChildElements()

Reimplemented in Fieldset, and HtmlForm.

Definition at line 137 of file Container.php.

◆ addHtml()

addHtml ( string $html)
Parameters
string$htmlHTML code
Returns
object $htmlElement HTML element object
See also
Depage\HtmlForm\Elements\Html

Definition at line 219 of file Container.php.

◆ addStepNav()

addStepNav ( array $parameter = [])
Parameters
array$parameterarray of opional parameters

Definition at line 232 of file Container.php.

◆ clearValue()

clearValue ( )
Returns
void

Reimplemented from Element.

Definition at line 284 of file Container.php.

◆ getElement()

getElement ( string $name,
bool $includeFieldsets = false )

Searches subelements by name and returns a single element object if successful. Returns false if the element can't be found.

Parameters
string$namename of the input element we're looking for
Returns
object $element subelement or (bool) false if unsuccessful

Definition at line 200 of file Container.php.

◆ getElements()

getElements ( bool $includeFieldsets = false)

Walks recursively through current containers' elements to compile a list of subelements.

Parameters
bool$includeFieldsetsinclude fieldset/step elements in result
Returns
array $allElements subelements

Definition at line 175 of file Container.php.

◆ setRequired()

setRequired ( bool $required = true)

Sets current containers' elements' HTML-required attribute recursively.

Parameters
bool$requiredHTML-required attribute
Returns
void

Definition at line 249 of file Container.php.

◆ validate()

validate ( )

Walks recursively through current containers' elements and checks if they're valid. Saves the result to $this->valid.

Returns
bool $this->valid validation result

Reimplemented in Address, Creditcard, and HtmlForm.

Definition at line 265 of file Container.php.

Field Documentation

◆ $elements

$elements = []
protected

Definition at line 64 of file Container.php.

◆ $elementsAndHtml

$elementsAndHtml = []
protected

Definition at line 68 of file Container.php.

◆ $form

$form
protected

Definition at line 72 of file Container.php.


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