PHP Class Habari\FormContainer

Inheritance: extends FormControl
Datei anzeigen Open project: habari/system

Public Properties

Property Type Description
$controls

Public Methods

Method Description
__get ( string $name ) : FormControl Magic property getter, returns the specified control
__isset ( string $name ) : boolean Magic property isset, returns if the specified control exists
append ( FormControl $control ) : FormControl | FormContainer Append a control to the end of this container
clear ( ) Reset the contained control values to their initial values
control_id ( ) : string Obtain a unique identifier for this control that is the same every time the form is generated
do_success ( FormUI $form ) : boolean | string Calls the success callback for the form, and optionally saves the form values to the options table.
each ( Callable $fn ) Apply a function to every control in this container, and any sub-containers
errors_get ( string $format, string $wrap = '%s' ) : string Return any validation errors on any controls in this container using the supplied format $this->validate must be called first!
errors_out ( $format, $wrap = '%s' ) Output any validation errors on any controls in this container using the supplied format $this->validate must be called first!
get ( Theme $theme ) : string Produce HTML output for all this fieldset and all contained controls
get_contents ( Theme $theme ) : string Get the control contents of this container
get_control ( string $name ) : FormControl | null Get a control from this container by name.
get_controls ( ) : array Returns an associative array of controls
get_value_out ( array $tag_fields ) : boolean | string Return the property value that is associated with the first present property from an array list This version only searches the list of the class' $properties array, because __get() on this objcet returns named FormControls instances
get_values ( ) : array Returns an associative array of the controls' values
insert ( FormControl $before, FormControl $control ) : FormControl
load ( ) Load this control and its children's initial data from the initialized storage location
move ( FormControl $source, FormControl $target, integer $offset ) Moves a control to target's position to which we add $int if specified That integer is useful to move before or move after the target
move_after ( FormControl $control, FormControl $target ) Moves a control after the target control
move_before ( FormControl $control, FormControl $target ) Moves a control before the target control
move_into ( FormControl $control, FormContainer $target ) Move a control into the container
pre_out ( ) : string Return the HTML/script required for all contained controls. Do it only once.
process ( ) Obtain the value of this control as supplied by the incoming $_POST values
remove ( FormControl $target ) Removes a target control from this group (can be the form or a fieldset)
replace ( FormControl $target, FormControl $control ) Replaces a target control by the supplied control
save ( ) Store each contained control's value under the control's specified key.
set_control_id ( string $control_id ) : FormControl Set the unique identifier for this control.
set_wrap_each ( string $wrap = '%s' ) : FormContainer Set a sprintf-style string that will wrap each control within this container with markup Use to create, for example,
%s
for each control in the container
validate ( ) : array Runs any attached validation functions to check validation of each control contained in this fieldset.

Method Details

__get() public method

Magic property getter, returns the specified control
public __get ( string $name ) : FormControl
$name string The name of the control
return FormControl The control object requested

__isset() public method

Magic property isset, returns if the specified control exists
public __isset ( string $name ) : boolean
$name string The name of the control
return boolean If the control object is set

append() public method

Append a control to the end of this container
public append ( FormControl $control ) : FormControl | FormContainer
$control FormControl A control to append to the end of this container
return FormControl | FormContainer The provided FormControl object, fluid

clear() public method

Reset the contained control values to their initial values
public clear ( )

control_id() public method

Obtain a unique identifier for this control that is the same every time the form is generated
public control_id ( ) : string
return string An md5 hash built using the controls contained within this container

do_success() public method

Calls the success callback for the form, and optionally saves the form values to the options table.
public do_success ( FormUI $form ) : boolean | string
$form FormUI The form for which success is being processed
return boolean | string A string to replace the rendering of the form with, or false

each() public method

Apply a function to every control in this container, and any sub-containers
public each ( Callable $fn )
$fn Callable A function with the signature (FormControl $control)

errors_get() public method

Return any validation errors on any controls in this container using the supplied format $this->validate must be called first!
public errors_get ( string $format, string $wrap = '%s' ) : string
$format string A sprintf()-style format string to format the validation error
$wrap string A sprintf()-style format string to wrap the returned error, only if at least one error exists
return string The errors in the supplied format

errors_out() public method

Output any validation errors on any controls in this container using the supplied format $this->validate must be called first!
public errors_out ( $format, $wrap = '%s' )

get() public method

Produce HTML output for all this fieldset and all contained controls
public get ( Theme $theme ) : string
$theme Theme The theme used to render the controls
return string HTML that will render this control in the form

get_contents() public method

Get the control contents of this container
public get_contents ( Theme $theme ) : string
$theme Theme The theme used to render the controls
return string The requested HTML output

get_control() public method

Get a control from this container by name.
public get_control ( string $name ) : FormControl | null
$name string The name of the control
return FormControl | null The control object requested, or null if not found

get_controls() public method

Returns an associative array of controls
public get_controls ( ) : array
return array An array of FormControls

get_value_out() public method

Return the property value that is associated with the first present property from an array list This version only searches the list of the class' $properties array, because __get() on this objcet returns named FormControls instances
public get_value_out ( array $tag_fields ) : boolean | string
$tag_fields array A list of potential fields to try
return boolean | string False if no value found, string of the property value found

get_values() public method

Returns an associative array of the controls' values
public get_values ( ) : array
return array Associative array where key is control's name and value is the control's value

insert() public method

public insert ( FormControl $before, FormControl $control ) : FormControl
$before FormControl The control to insert the control in front of
$control FormControl The control to insert
return FormControl $control via Fluent interface

load() public method

Load this control and its children's initial data from the initialized storage location
public load ( )

move() public method

Moves a control to target's position to which we add $int if specified That integer is useful to move before or move after the target
public move ( FormControl $source, FormControl $target, integer $offset )
$source FormControl FormControl object to move
$target FormControl FormControl object acting as destination
$offset integer Integer added to $target's position (index)

move_after() public method

Moves a control after the target control
public move_after ( FormControl $control, FormControl $target )
$control FormControl FormControl object to move
$target FormControl FormControl object acting as destination

move_before() public method

Moves a control before the target control
public move_before ( FormControl $control, FormControl $target )
$control FormControl FormControl object to move
$target FormControl FormControl object acting as destination

move_into() public method

Move a control into the container
public move_into ( FormControl $control, FormContainer $target )
$control FormControl FormControl object to move
$target FormContainer FormContainer object acting as destination

pre_out() public method

Return the HTML/script required for all contained controls. Do it only once.
public pre_out ( ) : string
return string The HTML/javascript required for all contained controls.

process() public method

Obtain the value of this control as supplied by the incoming $_POST values
public process ( )

remove() public method

Removes a target control from this group (can be the form or a fieldset)
public remove ( FormControl $target )
$target FormControl FormControl to remove

replace() public method

Replaces a target control by the supplied control
public replace ( FormControl $target, FormControl $control )
$target FormControl FormControl object to replace
$control FormControl FormControl object to replace $target with

save() public method

Store each contained control's value under the control's specified key.
public save ( )

set_control_id() public method

This DOES NOT set the id attribute of the output HTML for this control!
public set_control_id ( string $control_id ) : FormControl
$control_id string A unique value identifying this control internally
return FormControl $this

set_wrap_each() public method

Set a sprintf-style string that will wrap each control within this container with markup Use to create, for example,
%s
for each control in the container
public set_wrap_each ( string $wrap = '%s' ) : FormContainer
$wrap string The sprintf-style formatting string
return FormContainer $this

validate() public method

Runs any attached validation functions to check validation of each control contained in this fieldset.
public validate ( ) : array
return array An array of string validation error descriptions or an empty array if no errors were found.

Property Details

$controls public_oe property

public $controls