PHP Class lithium\template\helper\Form

For example: {{{// In controller code: $post = Post::find(1); return compact('post'); In view code: form->create($post); // Echoes a
tag and binds the helper to $post ?> form->text('title'); // Echoes an element, pre-filled with $post's title ?> form->submit('Update'); // Echoes a submit button with the title 'Update' ?> form->end(); // Echoes a
tag & unbinds the form ?> }}}
Inheritance: extends lithium\template\Helper
Show file Open project: unionofrad/lithium Class Usage Examples

Protected Properties

Property Type Description
$_binding - schema(): Returns an array defining the objects fields and their data types. - data(): Returns an associative array of the data that this object represents. - errors(): Returns an associate array of validation errors for the current data set, where the keys match keys from schema(), and the values are either strings (in cases where a field only has one error) or an array (in case of multiple errors), For an example of how to implement these methods, see the lithium\data\Entity object.
$_bindingOptions array Overwritten when end() is called.
$_strings array String templates used by this helper.
$_templateMap array For example, if all text input fields should be wrapped in tags, you can configure the template string mappings per the following: $this->form->config(array('templates' => array( 'text' => '' ))); Alternatively, you can re-map one type as another. This is useful if, for example, you include your own helper with custom form template strings which do not match the default template string names. Renders all password fields as text fields $this->form->config(array('templates' => array('password' => 'text')));

Public Methods

Method Description
__call ( string $type, array $params = [] ) : string Implements alternative input types as method calls against Form helper. Enables the generation of HTML5 input types and other custom input types:
__construct ( array $config = [] ) : void Constructor.
binding ( string $name = null ) : object Returns the entity that the Form helper is currently bound to.
button ( string $title = null, array $options = [] ) : string Generates an HTML button .
checkbox ( string $name, array $options = [] ) : string Generates an HTML object.
config ( array $config = [] ) : array Allows you to configure a default set of options which are included on a per-method basis, and configure method template overrides.
create ( mixed $bindings = null, array $options = [] ) : string Creates an HTML form, and optionally binds it to a data object which contains information on how to render form fields, any data to pre-populate the form with, and any validation errors.
end ( ) : string Echoes a closing tag and unbinds the Form helper from any Record or Document object used to generate the corresponding form.
error ( string $name, mixed $key = null, array $options = [] ) : string Generates an error message for a field which is part of an object bound to a form in create().
field ( mixed $name, array $options = [] ) : string Generates a form field with a label, input, and error message (if applicable), all contained within a wrapping element.
hidden ( string $name, array $options = [] ) : string Generates an HTML object.
label ( string $id, string $title = null, array $options = [] ) : string Generates an HTML object.
password ( string $name, array $options = [] ) : string Generates an HTML object.
radio ( string $name, array $options = [] ) : string Generates an HTML object.
respondsTo ( string $method, boolean $internal = false ) : boolean Determines if a given method can be called.
select ( string $name, array $list = [], array $options = [] ) : string Generates a
submit ( string $title = null, array $options = [] ) : string Generates an HTML object.
text ( string $name, array $options = [] ) : string Generates an HTML object.
textarea ( string $name, array $options = [] ) : string Generates an HTML `` object.
public textarea ( string $name, array $options = [] ) : string
$name string The name of the field.
$options array The options to be used when generating the `