FormHelper Class Reference

Public Member Functions | |
| button ($title, $options=array()) | |
| checkbox ($fieldName, $options=array()) | |
| create ($model=null, $options=array()) | |
| dateTime ($fieldName, $dateFormat= 'DMY', $timeFormat= '12', $selected=null, $attributes=array(), $showEmpty=true) | |
| day ($fieldName, $selected=null, $attributes=array(), $showEmpty=true) | |
| end ($options=null) | |
| error ($field, $text=null, $options=array()) | |
| file ($fieldName, $options=array()) | |
| hidden ($fieldName, $options=array()) | |
| hour ($fieldName, $format24Hours=false, $selected=null, $attributes=array(), $showEmpty=true) | |
| input ($fieldName, $options=array()) | |
| inputs ($fields=null, $blacklist=null) | |
| isFieldError ($field) | |
| label ($fieldName=null, $text=null, $attributes=array()) | |
| meridian ($fieldName, $selected=null, $attributes=array(), $showEmpty=true) | |
| minute ($fieldName, $selected=null, $attributes=array(), $showEmpty=true) | |
| month ($fieldName, $selected=null, $attributes=array(), $showEmpty=true) | |
| password ($fieldName, $options=array()) | |
| radio ($fieldName, $options=array(), $attributes=array()) | |
| secure ($fields) | |
| select ($fieldName, $options=array(), $selected=null, $attributes=array(), $showEmpty= '') | |
| submit ($caption=null, $options=array()) | |
| text ($fieldName, $options=array()) | |
| textarea ($fieldName, $options=array()) | |
| year ($fieldName, $minYear=null, $maxYear=null, $selected=null, $attributes=array(), $showEmpty=true) | |
Public Attributes | |
| $fields = array() | |
| $fieldset = array('fields' => array(), 'key' => 'id', 'validates' => array()) | |
| $helpers = array('Html') | |
| $requestType = null | |
Detailed Description
Definition at line 37 of file form.php.
Member Function Documentation
| FormHelper::button | ( | $ | title, | |
| $ | options = array() | |||
| ) |
Creates a button tag.
- Parameters:
-
string $title The button's caption array $options Array of options.
- Returns:
- string A HTML button tag. public
Definition at line 987 of file form.php.
References Helper::output(), and Helper::value().
| FormHelper::checkbox | ( | $ | fieldName, | |
| $ | options = array() | |||
| ) |
Creates a checkbox input widget.
- Parameters:
-
string $fieldNamem Name of a field, like this "Modelname.fieldname", "Modelname/fieldname" is deprecated array $options Array of HTML attributes. 'value' the value of the checkbox
- Returns:
- string An HTML text input element
Definition at line 796 of file form.php.
References $output, ConnectionManager::getDataSource(), ClassRegistry::getObject(), hidden(), ClassRegistry::isKeySet(), Helper::model(), Helper::output(), and Helper::value().
Referenced by input().
| FormHelper::create | ( | $ | model = null, |
|
| $ | options = array() | |||
| ) |
Returns an HTML FORM element.
public
- Parameters:
-
string $model The model object which the form is being defined for array $options 'type' Form method defaults to POST 'action' The Action the form submits to. Can be a string or array, 'url' The url the form submits to. Can be a string or a url array, 'default' Allows for the creation of Ajax forms. 'onsubmit' Used with 'default' to create ajax forms.
- Returns:
- string An formatted opening FORM tag.
Definition at line 89 of file form.php.
References Helper::$data, $fields, Inflector::camelize(), Set::countDim(), file(), ClassRegistry::getObject(), hidden(), ife(), ClassRegistry::isKeySet(), ClassRegistry::keys(), Helper::output(), params(), Inflector::pluralize(), Helper::setEntity(), Inflector::underscore(), Helper::url(), and Helper::value().
| FormHelper::dateTime | ( | $ | fieldName, | |
| $ | dateFormat = 'DMY', |
|||
| $ | timeFormat = '12', |
|||
| $ | selected = null, |
|||
| $ | attributes = array(), |
|||
| $ | showEmpty = true | |||
| ) |
Returns a set of SELECT elements for a full datetime setup: day, month and year, and then time.
- Parameters:
-
string $fieldName Prefix name for the SELECT element string $dateFormat DMY, MDY, YMD or NONE. string $timeFormat 12, 24, NONE string $selected Option which is selected. string $attributes array of Attributes 'monthNames' If set and false numbers will be used for month select instead of text. 'minYear' The lowest year to use in the year select 'maxYear' The maximum year to use in the year select 'interval' The interval for the minutes select. Defaults to 1 'separator' The contents of the string between select elements. Defaults to '-' bool $showEmpty Whether or not to show an empty default value.
- Returns:
- string The HTML formatted OPTION element
Definition at line 1370 of file form.php.
Referenced by input().
| FormHelper::day | ( | $ | fieldName, | |
| $ | selected = null, |
|||
| $ | attributes = array(), |
|||
| $ | showEmpty = true | |||
| ) |
Returns a SELECT element for days.
- Parameters:
-
string $fieldName Prefix name for the SELECT element string $selected Option which is selected. array $attributes HTML attributes for the select element mixed $showEmpty Show/hide the empty select option
- Returns:
- string
| FormHelper::end | ( | $ | options = null |
) |
Closes an HTML form, cleans up values set by FormHelper::create(), and writes hidden input fields where appropriate.
If $options is set a form submit button will be created.
- Parameters:
-
mixed $options as a string will use $options as the value of button, array usage: array('label' => 'save'); value="save" array('label' => 'save', 'name' => 'Whatever'); value="save" name="Whatever" array('name' => 'Whatever'); value="Submit" name="Whatever" array('label' => 'save', 'name' => 'Whatever', 'div' => 'good') value="save" name="Whatever" array('label' => 'save', 'name' => 'Whatever', 'div' => array('class' => 'good'));value="save" name="Whatever"
- Returns:
- string a closing FORM tag optional submit button. public
Definition at line 250 of file form.php.
References $out, ClassRegistry::getObject(), label(), Helper::output(), params(), secure(), Helper::setEntity(), and submit().
| FormHelper::error | ( | $ | field, | |
| $ | text = null, |
|||
| $ | options = array() | |||
| ) |
Returns a formatted error message for given FORM field, NULL if no errors.
- Parameters:
-
string $field A field name, like "Modelname.fieldname", "Modelname/fieldname" is deprecated mixed $text Error message or array of $options array $options Rendering options for wrapper tag 'escape' bool Whether or not to html escape the contents of the error. 'wrap' mixed Whether or not the error message should be wrapped in a div. If a string, will be used as the HTML tag to use. 'class' string The classname for the error message
- Returns:
- string If there are errors this method returns an error message, otherwise null. public
Definition at line 398 of file form.php.
References Helper::field(), Inflector::humanize(), Helper::setEntity(), and Helper::tagIsInvalid().
Referenced by input().
| FormHelper::file | ( | $ | fieldName, | |
| $ | options = array() | |||
| ) |
Creates file input widget.
- Parameters:
-
string $fieldName Name of a field, like this "Modelname.fieldname", "Modelname/fieldname" is deprecated array $options Array of HTML attributes.
- Returns:
- string public
Definition at line 974 of file form.php.
References Helper::output().
| FormHelper::hidden | ( | $ | fieldName, | |
| $ | options = array() | |||
| ) |
Creates a hidden input field.
- Parameters:
-
string $fieldName Name of a field, like this "Modelname.fieldname", "Modelname/fieldname" is deprecated array $options Array of HTML attributes.
- Returns:
- string public
Definition at line 947 of file form.php.
References Helper::model(), Helper::output(), params(), and Helper::value().
Referenced by checkbox(), create(), input(), radio(), and secure().
| FormHelper::hour | ( | $ | fieldName, | |
| $ | format24Hours = false, |
|||
| $ | selected = null, |
|||
| $ | attributes = array(), |
|||
| $ | showEmpty = true | |||
| ) |
Returns a SELECT element for hours.
- Parameters:
-
string $fieldName Prefix name for the SELECT element boolean $format24Hours True for 24 hours format string $selected Option which is selected. array $attributes List of HTML attributes mixed $showEmpty True to show an empty element, or a string to provide default empty element text
- Returns:
- string
| FormHelper::input | ( | $ | fieldName, | |
| $ | options = array() | |||
| ) |
Generates a form input element complete with label and wrapper div
- Parameters:
-
string $fieldName This should be "Modelname.fieldname", "Modelname/fieldname" is deprecated array $options - Each type of input takes different options. See each field type method for more information.
- Returns:
- string
Definition at line 552 of file form.php.
References $out, Helper::addClass(), checkbox(), dateTime(), Helper::domId(), error(), Helper::field(), file(), ClassRegistry::getObject(), hidden(), ClassRegistry::isKeySet(), label(), Helper::model(), password(), Inflector::pluralize(), radio(), select(), Helper::setEntity(), text(), textarea(), and Inflector::variable().
| FormHelper::inputs | ( | $ | fields = null, |
|
| $ | blacklist = null | |||
| ) |
Will display all the fields passed in an array expects fieldName as an array key replaces generateFields
public
- Parameters:
-
array $fields works well with Controller::generateFields() or on its own; array $blacklist a simple array of fields to skip
- Returns:
- output
Definition at line 485 of file form.php.
References $fields, $fieldset, $out, Inflector::humanize(), input(), Helper::model(), and Inflector::underscore().
| FormHelper::isFieldError | ( | $ | field | ) |
Returns true if there is an error for the given field, otherwise false
- Parameters:
-
string $field This should be "Modelname.fieldname", "Modelname/fieldname" is deprecated
- Returns:
- boolean If there are errors this method returns true, else false. public
Definition at line 382 of file form.php.
References Helper::setEntity(), and Helper::tagIsInvalid().
| FormHelper::label | ( | $ | fieldName = null, |
|
| $ | text = null, |
|||
| $ | attributes = array() | |||
| ) |
Returns a formatted LABEL element for HTML FORMs.
- Parameters:
-
string $fieldName This should be "Modelname.fieldname", "Modelname/fieldname" is deprecated string $text Text that will appear in the label field.
- Returns:
- string The formatted LABEL element
Definition at line 449 of file form.php.
References Helper::domId(), ClassRegistry::getObject(), Inflector::humanize(), Helper::output(), and Inflector::underscore().
| FormHelper::meridian | ( | $ | fieldName, | |
| $ | selected = null, |
|||
| $ | attributes = array(), |
|||
| $ | showEmpty = true | |||
| ) |
| FormHelper::minute | ( | $ | fieldName, | |
| $ | selected = null, |
|||
| $ | attributes = array(), |
|||
| $ | showEmpty = true | |||
| ) |
Returns a SELECT element for minutes.
- Parameters:
-
string $fieldName Prefix name for the SELECT element string $selected Option which is selected. string $attributes Array of Attributes bool $showEmpty True to show an empty element, or a string to provide default empty element text
- Returns:
- string
| FormHelper::month | ( | $ | fieldName, | |
| $ | selected = null, |
|||
| $ | attributes = array(), |
|||
| $ | showEmpty = true | |||
| ) |
Returns a SELECT element for months.
- Parameters:
-
string $fieldName Prefix name for the SELECT element string $selected Option which is selected. array $attributes Attributes for the select element If 'monthNames' is set and false 2 digit numbers will be used instead of text. boolean $showEmpty Show/hide the empty select option
- Returns:
- string
| FormHelper::password | ( | $ | fieldName, | |
| $ | options = array() | |||
| ) |
Creates a password input widget.
- Parameters:
-
string $fieldName Name of a field, like this "Modelname.fieldname", "Modelname/fieldname" is deprecated array $options Array of HTML attributes.
- Returns:
- string
Definition at line 913 of file form.php.
References Helper::output().
Referenced by input().
| FormHelper::radio | ( | $ | fieldName, | |
| $ | options = array(), |
|||
| $ | attributes = array() | |||
| ) |
Creates a set of radio widgets.
- Parameters:
-
string $fieldName Name of a field, like this "Modelname.fieldname" array $options Radio button options array. array $attributes Array of HTML attributes. Use the 'separator' key to define the string in between the radio buttons
- Returns:
- string
Definition at line 837 of file form.php.
References $out, Helper::_parseAttributes(), Inflector::camelize(), Helper::field(), hidden(), Inflector::humanize(), label(), Helper::model(), Helper::output(), Inflector::underscore(), and Helper::value().
Referenced by input().
| FormHelper::secure | ( | $ | fields | ) |
Generates a hidden field with a security hash based on the fields used in the form.
- Parameters:
-
array $fields The list of fields to use when generating the hash
- Returns:
- string A hidden input field with a security hash public
Definition at line 291 of file form.php.
References $fields, Security::hash(), hidden(), Configure::read(), and Helper::value().
| FormHelper::select | ( | $ | fieldName, | |
| $ | options = array(), |
|||
| $ | selected = null, |
|||
| $ | attributes = array(), |
|||
| $ | showEmpty = '' | |||
| ) |
Returns a formatted SELECT element.
- Parameters:
-
string $fieldName Name attribute of the SELECT array $options Array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the SELECT element mixed $selected The option selected by default. If null, the default value from POST data will be used when available. array $attributes The HTML attributes of the select element. If 'showParents' is included in the array and set to true, an additional option element will be added for the parent of each option group. mixed $showEmpty If true, the empty select option is shown. If a string, that string is displayed as the empty element.
- Returns:
- string Formatted SELECT element
Definition at line 1076 of file form.php.
Referenced by input().
| FormHelper::submit | ( | $ | caption = null, |
|
| $ | options = array() | |||
| ) |
Creates a submit button element.
- Parameters:
-
string $caption The label appearing on the button OR if string contains :// or the extension .jpg, .jpe, .jpeg, .gif, .png use an image if the extension exists, AND the first character is /, image is relative to webroot, OR if the first character is not /, image is relative to webroot/img, array $options
- Returns:
- string A HTML submit button
Definition at line 1010 of file form.php.
References $out, Helper::output(), params(), and secure().
Referenced by end().
| FormHelper::text | ( | $ | fieldName, | |
| $ | options = array() | |||
| ) |
Creates a text input widget.
- Parameters:
-
string $fieldNamem Name of a field, like this "Modelname.fieldname", "Modelname/fieldname" is deprecated array $options Array of HTML attributes.
- Returns:
- string An HTML text input element
Definition at line 901 of file form.php.
References input(), and Helper::output().
Referenced by input().
| FormHelper::textarea | ( | $ | fieldName, | |
| $ | options = array() | |||
| ) |
Creates a textarea widget.
- Parameters:
-
string $fieldNamem Name of a field, like this "Modelname.fieldname", "Modelname/fieldname" is deprecated array $options Array of HTML attributes.
- Returns:
- string An HTML text input element
Definition at line 925 of file form.php.
References Helper::output(), and Helper::value().
Referenced by input().
| FormHelper::year | ( | $ | fieldName, | |
| $ | minYear = null, |
|||
| $ | maxYear = null, |
|||
| $ | selected = null, |
|||
| $ | attributes = array(), |
|||
| $ | showEmpty = true | |||
| ) |
Returns a SELECT element for years
- Parameters:
-
string $fieldName Prefix name for the SELECT element integer $minYear First year in sequence integer $maxYear Last year in sequence string $selected Option which is selected. array $attributes Attribute array for the select elements. boolean $showEmpty Show/hide the empty select option
- Returns:
- string
Member Data Documentation
| FormHelper::$fields = array() |
| FormHelper::$fieldset = array('fields' => array(), 'key' => 'id', 'validates' => array()) |
| FormHelper::$helpers = array('Html') |
The documentation for this class was generated from the following file:
- 1.2.x.x/cake/libs/view/helpers/form.php