Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes

FormControl Class Reference

Inheritance diagram for FormControl:

List of all members.

Public Member Functions

 __construct ($name, $storage= 'null:null', array $properties=array(), array $settings=array())
 _extend ()
 set_storage ($storage)
 set_properties ($properties, $override=false)
 set_property ($name, $value)
 set_template_properties ($target, $properties, $override=false)
 set_settings ($settings, $override=false)
 set_setting ($name, $value)
 set_helptext ($helptext)
 get_theme ()
 prep_theme (Theme $theme_obj)
 get_template ()
 save ()
 load ()
 process ()
 control_id ()
 get (Theme $theme)
 wrap_by ($wrapper, $thing)
 control_type ()
 set_container ($container)
 set_template ($template)
 set_value ($value, $manually=true)
 set_template_html ($template)
 set_enable ($enabler)
 is_enabled ()
 get_setting ($name, $default=null)
 get_id ($force_set=true)
 get_id_component ()
 input_name ()
 add_input_array ($value)
 pop_input_array ()
 pre_out ()
 add_validator ($validator, $option=null)
 remove_validator ($name)
 validate ()
 add_class ($classes)
 add_template_class ($target, $classes)
 remove_class ($classes)
 get_form ()
 error_wrap ($output, $errors)
 label ($label)
 get_label ()
 clear ()
 do_success ($form)
 on_success ($callback)
 on_save ($callback)
 get_visualizer ()
 controls_js ($out)

Static Public Member Functions

static create ($name, $storage= 'null:null', array $properties=array(), array $settings=array())
static from_args ($arglist)

Public Attributes

 $name
 $storage
 $caption
 $properties = array()
 $settings = array()
 $value
 $initial_value
 $container
 $validators = array()
 $vars = array()
 $errors = array()
 $has_errors = false
 $value_set_manually = false
 $helptext = false
 $on_success = array()
 $on_save = array()
 $on_enable = array()

Static Public Attributes

static $controls_js = false

Detailed Description

Definition at line 5 of file formcontrol.php.


Constructor & Destructor Documentation

FormControl::__construct ( name,
storage = 'null:null',
array $  properties = array(),
array $  settings = array() 
)

Construct a control.

Parameters:
string $name The name of the control
FormStorage|string|null $storage A storage location for the data collected by the control
array $properties An array of properties that apply to the output HTML
array $settings An array of settings that apply to this control object

Reimplemented in FormControlDom, and FormControlText.

Definition at line 52 of file formcontrol.php.


Member Function Documentation

FormControl::_extend (  ) 
FormControl::add_class ( classes  ) 

Add one or more CSS classes to this control

Parameters:
array|string $classes An array or a string of classes to add to this control
Returns:
FormControl $this

Definition at line 754 of file formcontrol.php.

Referenced by Post::comment_form(), FormControlTree::get(), and get().

FormControl::add_input_array ( value  ) 

Add a value to the input_array setting

Parameters:
integer|string $value The value to use as the array part of the input name
Returns:
FormControl $this Fluent interface

Definition at line 634 of file formcontrol.php.

Referenced by FormControlRepeater::get().

FormControl::add_template_class ( target,
classes 
)

Add one or more CSS classes to this control's template

Parameters:
string $target The name of the targeted element in the control template
array|string $classes An array or a string of classes to add to this control's template
Returns:
FormControl $this

Definition at line 770 of file formcontrol.php.

Referenced by FormControlTabs::_extend(), FormControlFacet::_extend(), and FormControlDropbutton::_extend().

FormControl::add_validator ( validator,
option = null 
)

Add a validation function to this control Multiple parameters are passed as parameters to the validation function

Parameters:
mixed $validator A callback function
mixed $option Multiple parameters added to those used to call the validator callback
Returns:
FormControl Returns the control for chained execution

Definition at line 677 of file formcontrol.php.

Referenced by AdminUsersHandler::__construct(), AdminGroupsHandler::__construct(), and FormUI::__construct().

FormControl::clear (  ) 

Set this control to its initial value

Reimplemented in FormContainer.

Definition at line 863 of file formcontrol.php.

Referenced by FormContainer::clear().

FormControl::control_id (  ) 

Obtain a unique identifier for this control that is the same every time the form is generated

Returns:
string

Definition at line 330 of file formcontrol.php.

Referenced by FormUI::bounce(), FormUI::get(), FormUI::has_session_data(), FormUI::post_redirect(), and FormUI::set_from_error_values().

FormControl::control_type (  ) 

Get the type of control this is (without the "FormControl" and in lower case) Usually used for template selection

Returns:
string The type of the control in lower case

Definition at line 463 of file formcontrol.php.

Referenced by get_template(), and set_template().

FormControl::controls_js ( out  ) 

Render the controls.init script prior to the supplied script only if it hasn't already been rendered

Parameters:
string $out An existing script that depends on controls.init
Returns:
string The script with the controls.init script prepended, if needed

Definition at line 927 of file formcontrol.php.

Referenced by FormControlTree::pre_out(), FormControlTextMulti::pre_out(), FormControlDropbutton::pre_out(), FormControlAutocomplete::pre_out(), and FormControlAggregate::pre_out().

static FormControl::create ( name,
storage = 'null:null',
array $  properties = array(),
array $  settings = array() 
) [static]
FormControl::do_success ( form  ) 

Calls the success callback for the form, and saves the form value to the control's storage location

Parameters:
FormUI $form The form this control belongs to
Returns:
boolean|string A string to replace the rendering of the form with, or false

Reimplemented in FormControlDropbutton, and FormControlSubmit.

Definition at line 873 of file formcontrol.php.

Referenced by FormUI::get().

FormControl::error_wrap ( output,
errors 
)

Wrap the output of a control (or some text content) with error content

Parameters:
string $output The HTML to wrap
array $errors An array of error strings
Returns:
string The returned output

Definition at line 818 of file formcontrol.php.

Referenced by FormControlDom::get(), and get().

static FormControl::from_args ( arglist  )  [static]

Take an array of parameters, use the first as the FormControl class/type, and run the constructor with the rest

Parameters:
array $arglist The array of arguments
Exceptions:
\Exception When the requested type is invalid
Returns:
FormControl The created control.

Definition at line 89 of file formcontrol.php.

Referenced by FormContainer::append(), and FormContainer::insert().

FormControl::get ( Theme theme  ) 
FormControl::get_form (  ) 

Find the form that holds this control

Returns:
FormUI The form that this control is in

Definition at line 803 of file formcontrol.php.

Referenced by do_success(), FormControlFile::get(), FormControlDom::get(), and validate().

FormControl::get_id ( force_set = true  ) 

Produce a unique id (not name) for this control for use with labels and such, only if one is not provided in the control properties

Parameters:
bool $force_set Default to true, forcing the id to be set to the name of the control if it's not set already
Returns:
string|null The id of this control, or null if it's not set and not forced

Definition at line 585 of file formcontrol.php.

Referenced by FormControlTree::get(), FormControlAggregate::get(), FormUI::get(), get(), FormControlDropbutton::get_visualizer(), and get_visualizer().

FormControl::get_id_component (  ) 

Get a string that will be used to generate a component of a control's HTML id

Returns:
bool|string False if this component doesn't contribute to id creation, or the string component

Reimplemented in FormControlFieldset.

Definition at line 604 of file formcontrol.php.

FormControl::get_label (  ) 

Get a text label for this control

Returns:
string The label

Definition at line 849 of file formcontrol.php.

FormControl::get_setting ( name,
default = null 
)

Get the value of a setting

Parameters:
string $name The name of the setting to get
mixed $default The default value to use if the setting is not set
Returns:
mixed The value fo the setting or the default supplied

Definition at line 567 of file formcontrol.php.

Referenced by add_input_array(), control_id(), control_type(), FormControlDropbutton::do_success(), error_wrap(), FormControlWrapper::get(), FormControlTabs::get(), FormControlSubmit::get(), FormControlRepeater::get(), FormUI::get(), get(), get_id(), FormControlAggregate::get_label_id(), get_template(), input_name(), pop_input_array(), process(), and validate().

FormControl::get_template (  ) 

Get a list of potential templates that can render this control

Returns:
array An array of template names in fallback order

Definition at line 266 of file formcontrol.php.

Referenced by FormControlTag::get(), and get().

FormControl::get_theme (  ) 

Retreive the Theme used to display this form component and its descendants

Returns:
Theme The theme object to display the template for the control

Definition at line 234 of file formcontrol.php.

Referenced by FormControlTag::get(), and FormUI::get().

FormControl::get_visualizer (  ) 

Returns the HTML id of the element that the control exposes as a target, for example, for labels

Reimplemented in FormControlAggregate, FormControlDropbutton, and FormControlFacet.

Definition at line 917 of file formcontrol.php.

FormControl::input_name (  ) 

Get the name to use for the input field

Returns:
string The name to use in the HTML for this control

Definition at line 613 of file formcontrol.php.

Referenced by FormControlSubmit::do_success(), get(), FormControlCheckboxes::process(), FormControlCheckbox::process(), and FormControlSubmit::validate().

FormControl::is_enabled (  ) 

Determine if this controls should be enabled

Returns:
bool True if enabled, false if not enabled

Definition at line 552 of file formcontrol.php.

Referenced by get().

FormControl::label ( label  ) 

Shortcut to wrap this control in a label

Parameters:
string $label The caption of the label
Returns:
FormControlLabel The label control is returned. FYI, THIS BREAKS THE FLUENT INTERFACE.

Reimplemented in FormControlAggregate.

Definition at line 840 of file formcontrol.php.

Referenced by from_args(), FormControlLabel::set_label(), and FormControlLabel::wrap().

FormControl::load (  ) 

Load this control's initial data from the initialized storage location

Definition at line 296 of file formcontrol.php.

Referenced by FormUI::get().

FormControl::on_save ( callback  ) 

Set a function to call on form submission success

Parameters:
mixed $callback A callback function or a plugin filter name.
Returns:
FormControl $this Fluent interface

Definition at line 908 of file formcontrol.php.

Referenced by save().

FormControl::on_success ( callback  ) 

Set a function to call on form submission success

Parameters:
mixed $callback A callback function or a plugin filter name (FormUI $form)
Returns:
FormControl $this Fluent interface

Definition at line 896 of file formcontrol.php.

Referenced by AdminUsersHandler::__construct(), AdminGroupsHandler::__construct(), and do_success().

FormControl::pop_input_array (  ) 

Remove the most recent input_array setting

Returns:
FormControl $this Fluent interface

Definition at line 649 of file formcontrol.php.

Referenced by FormControlRepeater::get().

FormControl::pre_out (  ) 

Output this once when the control is first output to the page

Returns:
string

Reimplemented in FormControlAggregate, FormControlAutocomplete, FormControlDropbutton, FormControlFacet, FormControlTextMulti, and FormControlTree.

Definition at line 665 of file formcontrol.php.

FormControl::prep_theme ( Theme theme_obj  ) 
Parameters:
Theme $theme_obj
Returns:
Theme

Definition at line 249 of file formcontrol.php.

Referenced by get(), and get_theme().

FormControl::process (  ) 

Obtain the value of this control as supplied by the incoming $_POST values

Reimplemented in FormControlAggregate, FormControlCheckbox, FormControlCheckboxes, FormControlData, and FormControlTree.

Definition at line 306 of file formcontrol.php.

Referenced by FormUI::get().

FormControl::remove_class ( classes  ) 

Remove one or more CSS classes from this control

Parameters:
array|string $classes An array or a string of classes to remove from this control
Returns:
FormControl $this

Definition at line 790 of file formcontrol.php.

FormControl::remove_validator ( name  ) 

Removes a validation function from this control

Parameters:
string $name The name of the validator to remove

Definition at line 699 of file formcontrol.php.

FormControl::save (  ) 

Save this control's data to the initialized storage location

Definition at line 281 of file formcontrol.php.

Referenced by do_success(), and Block::save_block().

FormControl::set_container ( container  ) 

Set the container for this control

Parameters:
FormContainer $container A container that this control is inside
Returns:
$this

Definition at line 486 of file formcontrol.php.

FormControl::set_enable ( enabler  ) 

Set a function to use to determine if this control should be enabled or provided in the form

Parameters:
Callable $enabler A function to call to determine if this control should be enabled
Returns:
FormControl $this

Definition at line 542 of file formcontrol.php.

FormControl::set_helptext ( helptext  ) 
Parameters:
string $helptext Help text to appear for the control
Returns:
FormControl $this

Definition at line 222 of file formcontrol.php.

FormControl::set_properties ( properties,
override = false 
)

Set the HTML-related properties of this control

Parameters:
array $properties An array of properties that will be associated to this control's HTML output
bool $override If true, the supplied properties completely replace the existing ones
Returns:
FormControl $this

Definition at line 143 of file formcontrol.php.

Referenced by __construct(), FormControlTree::_extend(), Post::comment_form(), and FormControlSubmit::get().

FormControl::set_property ( name,
value 
)

Set an HTML-related property of this control

Parameters:
string $name The name of the property to set
mixed $value The value to set the property to
Returns:
FormControl $this

Definition at line 160 of file formcontrol.php.

FormControl::set_setting ( name,
value 
)

Set the value of a single setting

Parameters:
string $name The name of the setting
mixed $value The value of the setting
Returns:
FormControl $this Fluent interface

Definition at line 212 of file formcontrol.php.

Referenced by add_input_array(), Post::comment_form(), and pop_input_array().

FormControl::set_settings ( settings,
override = false 
)
Parameters:
array $settings An array of settings that affect the behavior of this control object
bool $override If true, use the provided array to override the existing one
Returns:
FormControl $this

Definition at line 195 of file formcontrol.php.

Referenced by AdminUsersHandler::__construct(), AdminGroupsHandler::__construct(), FormUI::__construct(), __construct(), FormControlWrapper::_extend(), FormControlRepeater::_extend(), FormControlAggregate::get(), FormControlAutocomplete::set_ajax(), FormControlSubmit::set_caption(), FormControlAggregate::set_label_id(), and FormControlSubmit::set_url().

FormControl::set_storage ( storage  ) 

Set the storage for this control

Parameters:
FormStorage|string|null $storage A storage location for the data collected by the control
Returns:
FormControl $this

Definition at line 128 of file formcontrol.php.

Referenced by __construct().

FormControl::set_template ( template  ) 

Set a template for use with this control

Parameters:
string|array $template A template fallback list to search for this template
Returns:
FormControl $this

Definition at line 497 of file formcontrol.php.

Referenced by FormUI::get().

FormControl::set_template_html ( template  ) 

Set an HTML value directly for the output of a control

Parameters:
Callable|string $template The template to use for output of this control
Returns:
FormControl $this

Definition at line 531 of file formcontrol.php.

FormControl::set_template_properties ( target,
properties,
override = false 
)

Set the HTML-related properties of this control's template

Parameters:
string $target the target element in the template to apply the properties to
array $properties An array of properties that will be associated to this control template's HTML output
bool $override If true, the supplied properties completely replace the existing ones
Returns:
FormControl $this

Definition at line 173 of file formcontrol.php.

FormControl::set_value ( value,
manually = true 
)

Set the value of the control

Parameters:
mixed $value The initial value of the control
bool $manually True if the value was set manually in code rather than being submitted
Returns:
FormControl $this

Reimplemented in FormControlCheckbox, and FormControlDom.

Definition at line 516 of file formcontrol.php.

Referenced by clear(), FormControlTree::process(), and process().

FormControl::validate (  ) 

Runs any attached validation functions to check validation of this control.

Returns:
array An array of string validation error descriptions or an empty array if no errors were found.

Reimplemented in FormControlSubmit.

Definition at line 715 of file formcontrol.php.

Referenced by FormUI::get().

FormControl::wrap_by ( wrapper,
thing 
)

Process a thing either using an sprintf-style string, or a closure

Parameters:
Callable|string $wrapper An sprintf-style wrapper or a function that accepts the same arguments as the call to this
mixed $thing One or more things to use as parameters to the sprintf/closure
Returns:
string The resultant string produced by applying the closure or sprintf template

Definition at line 446 of file formcontrol.php.

Referenced by error_wrap(), and get().


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