Container Class Reference

Detailed Description

container element base class

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

Definition at line 21 of file Container.php.

Public Member Functions

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

 addElement ($type, $name, $parameters)
 Generates sub-elements. 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

 $elements = array()
 References to input elements and fieldsets. More...
 
 $elementsAndHtml = array()
 Input element, fieldset and custom HTML object references. More...
 
 $form
 Parent form object reference. 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...
 
 $dataAttr
 Extra information about the data that is saved inside the element. More...
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $name,
  $parameters,
  $form 
)

container class constructor

Parameters
string$namecontainer name
array$parameterscontainer parameters, HTML attributes
object$formparent form object
Returns
void

Reimplemented from Element.

Reimplemented in Address, and HtmlForm.

Definition at line 43 of file Container.php.

Member Function Documentation

◆ __call()

__call (   $function,
  $arguments 
)

HTML escaping and add subelements.

  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 66 of file Container.php.

◆ addChildElements()

addChildElements ( )

Sub-element generator hook.

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 129 of file Container.php.

◆ addElement()

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

Generates sub-elements.

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 99 of file Container.php.

◆ addHtml()

addHtml (   $html)

Adds a new custom HTML element to the container.

Parameters
string$htmlHTML code
Returns
object $htmlElement HTML element object
See also
Depage::HtmlForm::Elements::Html

Definition at line 183 of file Container.php.

◆ addStepNav()

addStepNav (   $parameter = array())

Adds automatic step navigation to output.

Parameters
array$parameterarray of opional parameters

Definition at line 196 of file Container.php.

◆ clearValue()

clearValue ( )

Deletes values of all child elements.

Returns
void

Reimplemented from Element.

Definition at line 248 of file Container.php.

◆ getElement()

getElement (   $name,
  $includeFieldsets = false 
)

Gets subelement by name.

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 164 of file Container.php.

◆ getElements()

getElements (   $includeFieldsets = false)

Returns containers subelements.

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 139 of file Container.php.

◆ setRequired()

setRequired (   $required = true)

Sets required-attribute.

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

Parameters
bool$requiredHTML-required attribute
Returns
void

Definition at line 213 of file Container.php.

◆ validate()

validate ( )

Validates container and its contents.

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 229 of file Container.php.

Field Documentation

◆ $elements

$elements = array()
protected

References to input elements and fieldsets.

Definition at line 26 of file Container.php.

◆ $elementsAndHtml

$elementsAndHtml = array()
protected

Input element, fieldset and custom HTML object references.

Definition at line 30 of file Container.php.

◆ $form

$form
protected

Parent form object reference.

Definition at line 34 of file Container.php.


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