/ cake / libs / view / helpers / form.php
Defined Classes
FormHelper Class Info:
- Class Declaration:
class FormHelper extends AppHelper
- File name:
- cake/libs/view/helpers/form.php
- Description:
Form helper library.
Automatic generation of HTML FORMs from given data.
- Class Inheritance
- Package
- cake
- Subpackage
- cake.cake.libs.view.helpers
- Link
- http://book.cakephp.org/view/1383/Form
Properties:
-
action string
Current action.
-
argSeparator string
URL argument separator character
-
base string
Base URL
-
data array
POST data for models
-
defaultModel string
The default model being used for the current form.
-
fields array
List of fields created, used with secure forms.
-
fieldset
Holds the fields array('field_name' => array('type'=> 'string', 'length'=> 100), primaryKey and validates array('field_name')
-
helpers array
Other helpers used by FormHelper
-
here string
URL to current action.
-
_inputDefaults array
Persistent default options used by input(). Set by FormHelper::create().
-
namedArgs array
List of named arguments
-
__options array
Options used by DateTime fields
-
params array
Parameter array.
-
plugin string
Plugin path
-
requestType string
Defines the type of form being created. Set by FormHelper::create().
-
tags array
Holds tag templates.
-
theme string
The current theme name if any.
-
validationErrors array
Contains model validation errors of form post-backs
-
webroot string
Webroot path
Method Summary:
- addClass( $options = array ( ), $class = NULL, $key = 'class' )
- afterLayout( )
- afterRender( )
- assetTimestamp( $path )
- beforeLayout( )
- beforeRender( )
- button( $title, $options = array ( ) )
- cakeError( $method, $messages = array ( ) )
- call__( $method, $params )
- checkbox( $fieldName, $options = array ( ) )
- clean( $output )
- __construct( )
- create( $model = NULL, $options = array ( ) )
- dateTime( $fieldName, $dateFormat = 'DMY', $timeFormat = '12', $selected = NULL, $attributes = array ( ) )
- day( $fieldName, $selected = NULL, $attributes = array ( ) )
- dispatchMethod( $method, $params = array ( ) )
- domId( $options = NULL, $id = 'id' )
- end( $options = NULL )
- error( $field, $text = NULL, $options = array ( ) )
- _extractOption( $name, $options, $default = NULL )
- field( )
- file( $fieldName, $options = array ( ) )
- get__( $name )
- hidden( $fieldName, $options = array ( ) )
- hour( $fieldName, $format24Hours = false, $selected = NULL, $attributes = array ( ) )
- _initInputField( $field, $options = array ( ) )
- input( $fieldName, $options = array ( ) )
- _inputLabel( $fieldName, $label, $options )
- inputs( $fields = NULL, $blacklist = NULL )
- _introspectModel( $model )
- isFieldError( $field )
- _isRequiredField( $validateProperties )
- label( $fieldName = NULL, $text = NULL, $options = array ( ) )
- loadConfig( $name = 'tags' )
- log( $msg, $type = 2 )
- meridian( $fieldName, $selected = NULL, $attributes = array ( ) )
- minute( $fieldName, $selected = NULL, $attributes = array ( ) )
- model( )
- modelID( )
- month( $fieldName, $selected = NULL, $attributes = array ( ) )
- _name( $options = array ( ), $field = NULL, $key = 'name' )
- Object( )
- output( $str )
- overload( )
- _parseAttributes( $options, $exclude = NULL, $insertBefore = ' ', $insertAfter = NULL )
- password( $fieldName, $options = array ( ) )
- _persist( $name, $return, $object, $type = NULL )
- radio( $fieldName, $options = array ( ), $attributes = array ( ) )
- requestAction( $url, $extra = array ( ) )
- _savePersistent( $name, $object )
- secure( $fields = array ( ) )
- select( $fieldName, $options = array ( ), $selected = NULL, $attributes = array ( ) )
- _set( $properties = array ( ) )
- set__( $name, $value )
- setEntity( $entity, $setScope = false )
- _stop( $status = 0 )
- submit( $caption = NULL, $options = array ( ) )
- tagIsInvalid( $model = NULL, $field = NULL, $modelID = NULL )
- text( $fieldName, $options = array ( ) )
- textarea( $fieldName, $options = array ( ) )
- toString( )
- url( $url = NULL, $full = false )
- value( $options = array ( ), $field = NULL, $key = 'value' )
- webroot( $file )
- year( $fieldName, $minYear = NULL, $maxYear = NULL, $selected = NULL, $attributes = array ( ) )
addClass
topAdds the given class to the element options
- Parameters:
-
-
array $options optional array ( )
Array options/attributes to add a class to
-
string $class optional NULL
The classname being added.
-
string $key optional 'class'
the key to use for class.
-
- Method defined in:
- cake/libs/view/helper.php on line 754
- Return
array Array of options with $key set.
- Access
public
afterLayout
topAfter layout callback. afterLayout is called after the layout has rendered.
Overridden in subclasses.
- Method defined in:
- cake/libs/view/helper.php on line 818
- Return
void
- Access
public
afterRender
topAfter render callback. afterRender is called after the view file is rendered but before the layout has been rendered.
Overridden in subclasses.
- Method defined in:
- cake/libs/view/helper.php on line 796
- Return
void
- Access
public
assetTimestamp
topAdds a timestamp to a file based resource based on the value of Asset.timestamp in
Configure. If Asset.timestamp is true and debug > 0, or Asset.timestamp == 'force'
a timestamp will be added.
- Parameters:
-
-
string $path required
The file path to timestamp, the path must be inside WWW_ROOT
-
- Method defined in:
- cake/libs/view/helper.php on line 242
- Return
string Path with a timestamp added, or not.
- Access
public
beforeLayout
topBefore layout callback. beforeLayout is called before the layout is rendered.
Overridden in subclasses.
- Method defined in:
- cake/libs/view/helper.php on line 807
- Return
void
- Access
public
beforeRender
topBefore render callback. beforeRender is called before the view file is rendered.
Overridden in subclasses.
- Method defined in:
- cake/libs/view/helper.php on line 784
- Return
void
- Access
public
button
topCreates a <button> tag. The type attribute defaults to type="submit"
You can change it to a different value by using $options['type'].
Options:
escape- HTML entity encode the $title of the button. Defaults to false.
- Parameters:
-
-
string $title required
The button's caption. Not automatically HTML encoded
-
array $options optional array ( )
Array of options and HTML attributes.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1255
- Return
string A HTML button tag.
- Access
public
- Link
- http://book.cakephp.org/view/1415/button
cakeError
topUsed to report user friendly errors. If there is a file app/error.php or app/app_error.php this file will be loaded error.php is the AppError class it should extend ErrorHandler class.
- Parameters:
-
-
string $method required
Method to be called in the error class (AppError or ErrorHandler classes)
-
array $messages optional array ( )
Message that is to be displayed by the error class
-
- Method defined in:
- cake/libs/object.php on line 187
- Return
error message
- Access
public
call__
top- Parameters:
-
-
$method required
-
$params required
-
- Method defined in:
- cake/libs/view/helper.php on line 153
checkbox
topCreates a checkbox input widget.
Options:
value- the value of the checkboxchecked- boolean indicate that this checkbox is checked.hiddenField- boolean to indicate if you want the results of checkbox() to include a hidden input with a value of ''.disabled- create a disabled input.
- Parameters:
-
-
string $fieldName required
Name of a field, like this "Modelname.fieldname"
-
array $options optional array ( )
Array of HTML attributes.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 992
- Return
string An HTML text input element.
- Access
public
- Link
- http://book.cakephp.org/view/1414/checkbox
clean
topUsed to remove harmful tags from content. Removes a number of well known XSS attacks from content. However, is not guaranteed to remove all possiblities. Escaping content is the best way to prevent all possible attacks.
- Parameters:
-
-
mixed $output required
Either an array of strings to clean or a single string to clean.
-
- Method defined in:
- cake/libs/view/helper.php on line 263
- Return
cleaned content for output
- Access
public
__construct
topClass constructor, overridden in descendant classes.
- Method defined in:
- cake/libs/object.php on line 54
create
topReturns an HTML FORM element.
Options:
typeForm method defaults to POSTactionThe Action the form submits to. Can be a string or array,urlThe url the form submits to. Can be a string or a url array,defaultAllows for the creation of Ajax forms.onsubmitUsed in conjunction with 'default' to create ajax forms.inputDefaultsset the default $options for FormHelper::input(). Any options that would be set when using FormHelper::input() can be set here. Options set withinputDefaultscan be overridden when calling input()encodingSet the accept-charset encoding for the form. Defaults toConfigure::read('App.encoding')
- Parameters:
-
-
string $model optional NULL
The model object which the form is being defined for
-
array $options optional array ( )
An array of html attributes and options.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 190
- Access
public
- Return
string An formatted opening FORM tag.
- Link
- http://book.cakephp.org/view/1384/Creating-Forms
dateTime
topReturns a set of SELECT elements for a full datetime setup: day, month and year, and then time.
Attributes:
monthNamesIf false, 2 digit numbers will be used instead of text. If a array, the given array will be used.minYearThe lowest year to use in the year selectmaxYearThe maximum year to use in the year selectintervalThe interval for the minutes select. Defaults to 1separatorThe contents of the string between select elements. Defaults to '-'empty- If true, the empty select option is shown. If a string, that string is displayed as the empty element.
- Parameters:
-
-
string $fieldName required
Prefix name for the SELECT element
-
string $dateFormat optional 'DMY'
DMY, MDY, YMD.
-
string $timeFormat optional '12'
12, 24.
-
string $selected optional NULL
Option which is selected.
-
string $attributes optional array ( )
array of Attributes
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1782
- Return
string Generated set of select boxes for the date and time formats chosen.
- Access
public
- Link
- http://book.cakephp.org/view/1418/dateTime
day
topReturns a SELECT element for days.
Attributes:
empty- If true, the empty select option is shown. If a string, that string is displayed as the empty element.
- Parameters:
-
-
string $fieldName required
Prefix name for the SELECT element
-
string $selected optional NULL
Option which is selected.
-
array $attributes optional array ( )
HTML attributes for the select element
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1513
- Return
string A generated day select box.
- Access
public
- Link
- http://book.cakephp.org/view/1419/day
dispatchMethod
topCalls a method on this object with the given parameters. Provides an OO wrapper
for call_user_func_array
- Parameters:
-
-
string $method required
Name of the method to call
-
array $params optional array ( )
Parameter list to use when calling $method
-
- Method defined in:
- cake/libs/object.php on line 107
- Return
mixed Returns the result of the method call
- Access
public
domId
topGenerates a DOM ID for the selected element, if one is not set. Uses the current View::entity() settings to generate a CamelCased id attribute.
- Parameters:
-
-
mixed $options optional NULL
Either an array of html attributes to add $id into, or a string with a view entity path to get a domId for.
-
string $id optional 'id'
The name of the 'id' attribute.
-
- Method defined in:
- cake/libs/view/helper.php on line 584
- Return
mixed If $options was an array, an array will be returned with $id set. If a string was supplied, a string will be returned.
- Todo
Refactor this method to not have as many input/output options.
end
topCloses 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. Options can be either a string or an array.
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') <div class="good"> value="save" name="Whatever"
array('label' => 'save', 'name' => 'Whatever', 'div' => array('class' => 'good')); <div class="good"> value="save" name="Whatever"
- Parameters:
-
-
mixed $options optional NULL
as a string will use $options as the value of button,
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 345
- Return
string a closing FORM tag optional submit button.
- Access
public
- Link
- http://book.cakephp.org/view/1389/Closing-the-Form
error
topReturns a formatted error message for given FORM field, NULL if no errors.
Options:
escapebool Whether or not to html escape the contents of the error.wrapmixed Whether or not the error message should be wrapped in a div. If a string, will be used as the HTML tag to use.classstring The classname for the error message
will get used as html attributes for error container
- Parameters:
-
-
string $field required
A field name, like "Modelname.fieldname"
-
mixed $text optional NULL
Error message or array of $options. If array,
attributeskey -
array $options optional array ( )
Rendering options for <div /> wrapper tag
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 480
- Return
string If there are errors this method returns an error message, otherwise null.
- Access
public
- Link
- http://book.cakephp.org/view/1423/error
_extractOption
topExtracts a single option from an options array.
- Parameters:
-
-
string $name required
The name of the option to pull out.
-
array $options required
The array of options you want to extract.
-
mixed $default optional NULL
The default option value
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 924
- Return
the contents of the option or default
- Access
protected
field
topGets the currently-used model field of the rendering context.
- Method defined in:
- cake/libs/view/helper.php on line 550
- Return
string
- Access
public
file
topCreates file input widget.
- Parameters:
-
-
string $fieldName required
Name of a field, in the form "Modelname.fieldname"
-
array $options optional array ( )
Array of HTML attributes.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1227
- Return
string A generated file input.
- Access
public
- Link
- http://book.cakephp.org/view/1424/file
get__
topDefault overload methods
- Parameters:
-
-
$name required
-
- Method defined in:
- cake/libs/view/helper.php on line 151
- Access
protected
hidden
topCreates a hidden input field.
- Parameters:
-
-
string $fieldName required
Name of a field, in the form of "Modelname.fieldname"
-
array $options optional array ( )
Array of HTML attributes.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1195
- Return
string A generated hidden input
- Access
public
- Link
- http://book.cakephp.org/view/1425/hidden
hour
topReturns a SELECT element for hours.
Attributes:
empty- If true, the empty select option is shown. If a string, that string is displayed as the empty element.
- Parameters:
-
-
string $fieldName required
Prefix name for the SELECT element
-
boolean $format24Hours optional false
True for 24 hours format
-
string $selected optional NULL
Option which is selected.
-
array $attributes optional array ( )
List of HTML attributes
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1634
- Return
string Completed hour select input
- Access
public
- Link
- http://book.cakephp.org/view/1420/hour
_initInputField
topSets field defaults and adds field to form security input hash
Options
secure- boolean whether or not the the field should be added to the security fields.
- Parameters:
-
-
string $field required
Name of the field to initialize options for.
-
array $options optional array ( )
Array of options to append options into.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 2167
- Return
array Array of options for the input.
- Access
protected
input
topGenerates a form input element complete with label and wrapper div
Options
See each field type method for more information. Any options that are part of
$attributes or $options for the different type methods can be included in $options for input().
type- Force the type of widget you want. e.g.type => 'select'label- Either a string label, or an array of options for the label. See FormHelper::label()div- Eitherfalseto disable the div, or an array of options for the div. See HtmlHelper::div() for more options.options- for widgets that take options e.g. radio, selecterror- control the error message that is producedempty- String or boolean to enable empty select box options.before- Content to place before the label + input.after- Content to place after the label + input.between- Content to place between the label + input.format- format template for element order. Any element that is not in the array, will not be in the output.- Default input format order: array('before', 'label', 'between', 'input', 'after', 'error')
- Default checkbox format order: array('before', 'input', 'between', 'label', 'after', 'error')
- Hidden input will not be formatted
- Radio buttons cannot have the order of input and label elements controlled with these settings.
- Parameters:
-
-
string $fieldName required
This should be "Modelname.fieldname"
-
array $options optional array ( )
Each type of input takes different options.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 698
- Return
string Completed form widget.
- Access
public
- Link
- http://book.cakephp.org/view/1390/Automagic-Form-Elements
_inputLabel
topGenerate a label for an input() call.
- Parameters:
-
-
$fieldName required
-
$label required
-
array $options required
Options for the label element.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 938
- Return
string Generated label element
- Access
protected
inputs
topGenerate a set of inputs for $fields. If $fields is null the current model
will be used.
In addition to controller fields output, $fields can be used to control legend
and fieldset rendering with the fieldset and legend keys.
$form->inputs(array('legend' => 'My legend')); Would generate an input set with
a custom legend. You can customize individual inputs through $fields as well.
$form->inputs(array(
'name' => array('label' => 'custom label')
));
- Parameters:
-
-
mixed $fields optional NULL
An array of fields to generate inputs for, or null.
-
array $blacklist optional NULL
a simple array of fields to not create inputs for.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 594
- Return
string Completed form inputs.
- Access
public
_introspectModel
topIntrospects model information and extracts information related to validation, field length and field type. Appends information into $this->fieldset.
- Parameters:
-
-
$model required
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 101
- Return
Model Returns a model instance
- Access
protected
isFieldError
topReturns true if there is an error for the given field, otherwise false
- Parameters:
-
-
string $field required
This should be "Modelname.fieldname"
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 457
- Return
boolean If there are errors this method returns true, else false.
- Access
public
- Link
- http://book.cakephp.org/view/1426/isFieldError
_isRequiredField
topReturns if a field is required to be filled based on validation properties from the validating object
- Parameters:
-
-
$validateProperties required
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 146
- Return
boolean true if field is required to be filled, false otherwise
- Access
protected
label
topReturns a formatted LABEL element for HTML FORMs. Will automatically generate a for attribute if one is not provided.
- Parameters:
-
-
string $fieldName optional NULL
This should be "Modelname.fieldname"
-
string $text optional NULL
Text that will appear in the label field.
-
mixed $options optional array ( )
An array of HTML attributes, or a string, to be used as a class name.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 538
- Return
string The formatted LABEL element
- Link
- http://book.cakephp.org/view/1427/label
loadConfig
topParses tag templates into $this->tags.
- Parameters:
-
-
$name optional 'tags'
-
- Method defined in:
- cake/libs/view/helper.php on line 164
- Return
array merged tags from config/$name.php
- Access
public
log
topConvience method to write a message to CakeLog. See CakeLog::write() for more information on writing to logs.
- Parameters:
-
-
string $msg required
Log message
-
integer $type optional 2
Error type constant. Defined in app/config/core.php.
-
- Method defined in:
- cake/libs/object.php on line 148
- Return
boolean Success of log write
- Access
public
meridian
topReturns a SELECT element for AM or PM.
Attributes:
empty- If true, the empty select option is shown. If a string, that string is displayed as the empty element.
- Parameters:
-
-
string $fieldName required
Prefix name for the SELECT element
-
string $selected optional NULL
Option which is selected.
-
string $attributes optional array ( )
Array of Attributes
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1733
- Return
string Completed meridian select input
- Access
public
- Link
- http://book.cakephp.org/view/1422/meridian
minute
topReturns a SELECT element for minutes.
Attributes:
empty- If true, the empty select option is shown. If a string, that string is displayed as the empty element.
- Parameters:
-
-
string $fieldName required
Prefix name for the SELECT element
-
string $selected optional NULL
Option which is selected.
-
string $attributes optional array ( )
Array of Attributes
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1669
- Return
string Completed minute select input.
- Access
public
- Link
- http://book.cakephp.org/view/1421/minute
model
topGets the currently-used model of the rendering context.
- Method defined in:
- cake/libs/view/helper.php on line 524
- Return
string
- Access
public
modelID
topGets the ID of the currently-used model of the rendering context.
- Method defined in:
- cake/libs/view/helper.php on line 539
- Return
mixed
- Access
public
month
topReturns a SELECT element for months.
Attributes:
monthNames- If false, 2 digit numbers will be used instead of text. If a array, the given array will be used.empty- If true, the empty select option is shown. If a string, that string is displayed as the empty element.
- Parameters:
-
-
string $fieldName required
Prefix name for the SELECT element
-
string $selected optional NULL
Option which is selected.
-
array $attributes optional array ( )
Attributes for the select element
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1597
- Return
string A generated month select dropdown.
- Access
public
- Link
- http://book.cakephp.org/view/1417/month
_name
topGets the input field name for the current tag
- Parameters:
-
-
array $options optional array ( )
-
$field optional NULL
-
string $key optional 'name'
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1927
- Return
array
- Access
protected
Object
topA hack to support __construct() on PHP 4 Hint: descendant classes have no PHP4 class_name() constructors, so this constructor gets called first and calls the top-layer __construct() which (if present) should call parent::__construct()
- Method defined in:
- cake/libs/object.php on line 43
- Return
Object
output
topReturns a string generated by a helper method
This method can be overridden in subclasses to do generalized output post-processing
- Parameters:
-
-
string $str required
String to be output.
-
- Method defined in:
- cake/libs/view/helper.php on line 772
- Return
string
- Deprecated
This method will be removed in future versions.
overload
topOverload implementation. No need for implementation in PHP5.
- Method defined in:
- cake/libs/overloadable_php5.php on line 36
- Access
public
_parseAttributes
topReturns a space-delimited string with items of the $options array. If a key of $options array happens to be one of:
- 'compact'
- 'checked'
- 'declare'
- 'readonly'
- 'disabled'
- 'selected'
- 'defer'
- 'ismap'
- 'nohref'
- 'noshade'
- 'nowrap'
- 'multiple'
- 'noresize'
And its value is one of:
- 1
- true
- 'true'
Then the value will be reset to be identical with key's name. If the value is not one of these 3, the parameter is not output.
'escape' is a special option in that it controls the conversion of attributes to their html-entity encoded equivalents. Set to false to disable html-encoding.
If value for any option key is set to null or false, that option will be excluded from output.
- Parameters:
-
-
array $options required
Array of options.
-
array $exclude optional NULL
Array of options to be excluded, the options here will not be part of the return.
-
string $insertBefore optional ' '
String to be inserted before options.
-
string $insertAfter optional NULL
String to be inserted after options.
-
- Method defined in:
- cake/libs/view/helper.php on line 318
- Return
string Composed attributes.
- Access
public
password
topCreates a password input widget.
- Parameters:
-
-
string $fieldName required
Name of a field, like in the form "Modelname.fieldname"
-
array $options optional array ( )
Array of HTML attributes.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1145
- Return
string A generated password input.
- Access
public
- Link
- http://book.cakephp.org/view/1428/password
_persist
topChecks for a persistent class file, if found file is opened and true returned If file is not found a file is created and false returned If used in other locations of the model you should choose a unique name for the persistent file There are many uses for this method, see manual for examples
- Parameters:
-
-
string $name required
name of the class to persist
-
$return required
-
string $object required
the object to persist
-
$type optional NULL
-
- Method defined in:
- cake/libs/object.php on line 218
- Return
boolean Success
- Access
protected
- Todo
add examples to manual
radio
topCreates a set of radio widgets. Will create a legend and fieldset by default. Use $options to control this
Attributes:
separator- define the string in between the radio buttonslegend- control whether or not the widget set has a fieldset & legendvalue- indicate a value that is should be checkedlabel- boolean to indicate whether or not labels for widgets show be displayedhiddenField- boolean to indicate if you want the results of radio() to include a hidden input with a value of ''. This is useful for creating radio sets that non-continuous
- Parameters:
-
-
string $fieldName required
Name of a field, like this "Modelname.fieldname"
-
array $options optional array ( )
Radio button options array.
-
array $attributes optional array ( )
Array of HTML attributes, and special attributes above.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1041
- Return
string Completed radio widget set.
- Access
public
- Link
- http://book.cakephp.org/view/1429/radio
requestAction
topCalls a controller's method from any location. Can be used to connect controllers together or tie plugins into a main application. requestAction can be used to return rendered views or fetch the return value from controller actions.
- Parameters:
-
-
mixed $url required
String or array-based url.
-
array $extra optional array ( )
if array includes the key "return" it sets the AutoRender to true.
-
- Method defined in:
- cake/libs/object.php on line 80
- Return
mixed Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.
- Access
public
_savePersistent
topYou should choose a unique name for the persistent file
There are many uses for this method, see manual for examples
- Parameters:
-
-
string $name required
name used for object to cache
-
object $object required
the object to persist
-
- Method defined in:
- cake/libs/object.php on line 247
- Return
boolean true on save, throws error if file can not be created
- Access
protected
secure
topGenerates a hidden field with a security hash based on the fields used in the form.
- Parameters:
-
-
array $fields optional array ( )
The list of fields to use when generating the hash
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 388
- Return
string A hidden input field with a security hash
- Access
public
select
topReturns a formatted SELECT element.
Attributes:
showParents- If included in the array and set to true, an additional option element will be added for the parent of each option group. You can set an option with the same name and it's key will be used for the value of the option.multiple- show a multiple select box. If set to 'checkbox' multiple checkboxes will be created instead.empty- If true, the empty select option is shown. If a string, that string is displayed as the empty element.escape- If true contents of options will be HTML entity encoded. Defaults to true.
Using options
A simple array will create normal options:
$options = array(1 => 'one', 2 => 'two);
$this->Form->select('Model.field', $options));
While a nested options array will create optgroups with options inside them.
$options = array(
1 => 'bill',
'fred' => array(
2 => 'fred',
3 => 'fred jr.'
)
);
$this->Form->select('Model.field', $options);
In the above 2 => 'fred' will not generate an option element. You should enable the showParents
attribute to show the fred option.
- Parameters:
-
-
string $fieldName required
Name attribute of the SELECT
-
array $options optional array ( )
Array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the SELECT element
-
mixed $selected optional NULL
The option selected by default. If null, the default value from POST data will be used when available.
-
array $attributes optional array ( )
The HTML attributes of the select element.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1409
- Return
string Formatted SELECT element
- Access
public
- Link
- http://book.cakephp.org/view/1430/select
_set
topAllows setting of multiple properties of the object in a single line of code. Will only set properties that are part of a class declaration.
- Parameters:
-
-
array $properties optional array ( )
An associative array containing properties and corresponding values.
-
- Method defined in:
- cake/libs/object.php on line 166
- Return
void
- Access
protected
set__
topsetEntity
topSets this helper's model and field properties to the dot-separated value-pair in $entity.
- Parameters:
-
-
mixed $entity required
A field name, like "ModelName.fieldName" or "ModelName.ID.fieldName"
-
boolean $setScope optional false
Sets the view scope to the model specified in $tagValue
-
- Method defined in:
- cake/libs/view/helper.php on line 378
- Return
void
- Access
public
_stop
topStop execution of the current script. Wraps exit() making testing easier.
- Parameters:
-
-
$status optional 0
-
- Method defined in:
- cake/libs/object.php on line 135
- Return
void
- Access
public
submit
topCreates a submit button element. This method will generate <input /> elements that
can be used to submit, and reset forms by using $options. image submits can be created by supplying an
image path for $caption.
Options
div- Include a wrapping div? Defaults to true. Accepts sub options similar to FormHelper::input().before- Content to include before the input.after- Content to include after the input.type- Set to 'reset' for reset inputs. Defaults to 'submit'- Other attributes will be assigned to the input element.
Options
div- Include a wrapping div? Defaults to true. Accepts sub options similar to FormHelper::input().- Other attributes will be assigned to the input element.
- Parameters:
-
-
string $caption optional NULL
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 optional array ( )
Array of options. See above.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1297
- Return
string A HTML submit button
- Access
public
- Link
- http://book.cakephp.org/view/1431/submit
tagIsInvalid
topReturns false if given FORM field has no errors. Otherwise it returns the constant set in the array Model->validationErrors.
- Parameters:
-
-
string $model optional NULL
Model name as a string
-
string $field optional NULL
Fieldname as a string
-
integer $modelID optional NULL
Unique index identifying this record within the form
-
- Method defined in:
- cake/libs/view/helper.php on line 564
- Return
boolean True on errors.
text
topCreates a text input widget.
- Parameters:
-
-
string $fieldName required
Name of a field, in the form "Modelname.fieldname"
-
array $options optional array ( )
Array of HTML attributes.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1125
- Return
string A generated HTML text input element
- Access
public
- Link
- http://book.cakephp.org/view/1432/text
textarea
topCreates a textarea widget.
Options:
escape- Whether or not the contents of the textarea should be escaped. Defaults to true.
- Parameters:
-
-
string $fieldName required
Name of a field, in the form "Modelname.fieldname"
-
array $options optional array ( )
Array of HTML attributes, and special options above.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1167
- Return
string A generated HTML text input element
- Access
public
- Link
- http://book.cakephp.org/view/1433/textarea
toString
topObject-to-string conversion. Each class can override this method as necessary.
- Method defined in:
- cake/libs/object.php on line 64
- Return
string The name of this class
- Access
public
url
topFinds URL for specified action.
Returns a URL pointing at the provided parameters.
- Parameters:
-
-
mixed $url optional NULL
Either a relative string url like
/products/view/23or an array of url parameters. Using an array for urls will allow you to leverage the reverse routing features of CakePHP. -
boolean $full optional false
If true, the full base URL will be prepended to the result
-
- Method defined in:
- cake/libs/view/helper.php on line 187
- Return
string Full translated URL with base path.
- Access
public
- Link
- http://book.cakephp.org/view/1448/url
value
topGets the data for the current tag
- Parameters:
-
-
mixed $options optional array ( )
If an array, should be an array of attributes that $key needs to be added to. If a string or null, will be used as the View entity.
-
string $field optional NULL
If an array, should be an array of attributes that $key needs to be added to. If a string or null, will be used as the View entity.
-
string $key optional 'value'
The name of the attribute to be set, defaults to 'value'
-
- Method defined in:
- cake/libs/view/helper.php on line 666
- Return
mixed If an array was given for $options, an array with $key set will be returned. If a string was supplied a string will be returned.
- Access
public
- Todo
Refactor this method to not have as many input/output options.
webroot
topChecks if a file exists when theme is used, if no file is found default location is returned
- Parameters:
-
-
string $file required
The file to create a webroot path to.
-
- Method defined in:
- cake/libs/view/helper.php on line 198
- Return
string Web accessible path to file.
- Access
public
year
topReturns a SELECT element for years
Attributes:
empty- If true, the empty select option is shown. If a string, that string is displayed as the empty element.orderYear- Ordering of year values in select options. Possible values 'asc', 'desc'. Default 'desc'
- Parameters:
-
-
string $fieldName required
Prefix name for the SELECT element
-
integer $minYear optional NULL
First year in sequence
-
integer $maxYear optional NULL
Last year in sequence
-
string $selected optional NULL
Option which is selected.
-
array $attributes optional array ( )
Attribute array for the select elements.
-
- Method defined in:
- cake/libs/view/helpers/form.php on line 1544
- Return
string Completed year select input
- Access
public
- Link
- http://book.cakephp.org/view/1416/year