PHP Class Habari\FormUI

For a list of options to customize its output or behavior see FormUI::set_option()
Inheritance: extends FormContainer, implements IsContent
Show file Open project: habari/system Class Usage Examples

Public Properties

Property Type Description
$dom
$formtype
$properties
$registered_forms
$submitted
$success
$success_render If this is not false, this value should be rendered instead of the form as a success response

Public Methods

Method Description
__construct ( string $name, string $formtype = null, array $extra_data = [] ) FormUI's constructor, called on instantiation.
__toString ( ) : string Convert this object instance to a string
bounce ( $keep_hash = true ) Redirect the user back to the stored URL value in session
build ( string $name, string $formtype = null, array $extra_data = [] ) : FormUI Create a new instance of this class and return it, use the fluent interface
content_type ( ) : array Implementation of IsContent
dupe ( Theme $theme = null ) : string Produce a form "duplicate" that does not process the form, display output, or include one-time-javascripts
from_html ( string $name, string $html ) : FormUI Create a form with controls from HTML
get ( Theme $theme = null ) : string Produce a form with the contained fields.
get_id_component ( ) : string Get a string that will be used to generate a component of a control's HTML id
has_session_data ( ) : boolean Get whether there is session data stored for this form
media_panel ( string $path, string $panel, string $callback ) Configure all the options necessary to make this form work inside a media bar panel
out ( ) Output a form with the contained fields.
output_controls ( Theme $theme ) : string Return the form control HTML.
post_redirect ( string $url = null ) : string Process a form, then redirect, saving control values on errors for redisplay
pre_out_controls ( ) : string Return pre-output control configuration scripts for any controls that require them.
register ( string $name, Callable $build_callback ) Register a function to use to create a new form
set_from_error_values ( ) Set the values of the form controls from their session error values, if stored
simulate ( array $data, boolean $do_wsse_and_id = false ) Simulate posting data to this form

Method Details

__construct() public method

FormUI's constructor, called on instantiation.
public __construct ( string $name, string $formtype = null, array $extra_data = [] )
$name string The name of the form, used to differentiate multiple forms.
$formtype string The type of the form, used to classify form types for plugin modification
$extra_data array An array of extra data that can be passed into the form

__toString() public method

Convert this object instance to a string
public __toString ( ) : string
return string The form as HTML

bounce() public method

Redirect the user back to the stored URL value in session
public bounce ( $keep_hash = true )

build() public static method

Create a new instance of this class and return it, use the fluent interface
public static build ( string $name, string $formtype = null, array $extra_data = [] ) : FormUI
$name string The name of the form to build
$formtype string The type of the form
$extra_data array Extra data to pass to the form for configuration purposes
return FormUI The instance of the created form

content_type() public method

Implementation of IsContent
public content_type ( ) : array
return array An array of content types that this object represents, starting with the most specific

dupe() public method

Produce a form "duplicate" that does not process the form, display output, or include one-time-javascripts
public dupe ( Theme $theme = null ) : string
$theme Theme The theme to render the controls into
return string HTML form generated from all controls assigned to this form

from_html() public static method

Create a form with controls from HTML
public static from_html ( string $name, string $html ) : FormUI
$name string Name of the form
$html string HTML of a form
return FormUI The form created from the supplied HTML

get() public method

Produce a form with the contained fields.
public get ( Theme $theme = null ) : string
$theme Theme The theme to render the controls into
return string HTML form generated from all controls assigned to this form

get_id_component() public method

Get a string that will be used to generate a component of a control's HTML id
public get_id_component ( ) : string
return string

has_session_data() public method

Get whether there is session data stored for this form
public has_session_data ( ) : boolean
return boolean True if this form has session data set

media_panel() public method

Configure all the options necessary to make this form work inside a media bar panel
public media_panel ( string $path, string $panel, string $callback )
$path string Identifies the silo
$panel string The panel in the silo to submit to
$callback string Javascript function to call on form submission

out() public method

Calls $this->get() and echoes.
public out ( )

output_controls() public method

Return the form control HTML.
public output_controls ( Theme $theme ) : string
$theme Theme The theme used to render the controls
return string The output of controls' HTML.

post_redirect() public method

Process a form, then redirect, saving control values on errors for redisplay
public post_redirect ( string $url = null ) : string
$url string The URL to redirect to, presumably with the original form on it
return string The form output, if needed

pre_out_controls() public method

Return pre-output control configuration scripts for any controls that require them.
public pre_out_controls ( ) : string
return string The output of controls' pre-output HTML.

register() public static method

Register a function to use to create a new form
public static register ( string $name, Callable $build_callback )
$name string The name of the form to register
$build_callback Callable The method to call to customize a form instance (FormUI $form, string $name, string $form_type)

set_from_error_values() public method

Set the values of the form controls from their session error values, if stored

simulate() public method

Simulate posting data to this form
public simulate ( array $data, boolean $do_wsse_and_id = false )
$data array An associative array of data to simultae adding to the $_POST array
$do_wsse_and_id boolean Default is false. If true, add this form's id and correct WSSE values to the $_POST array

Property Details

$dom public property

public $dom

$formtype public property

public $formtype

$properties public property

public $properties

$registered_forms public static property

public static $registered_forms

$submitted public property

public $submitted

$success public property

public $success

$success_render public property

If this is not false, this value should be rendered instead of the form as a success response
public $success_render