/ 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

AppHelper Helper Overloadable Object

Properties:

Show/Hide parent 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:

Show/Hide parent methods

addClass

top

Adds 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

top

After 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

top

After 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

top

Adds 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

top

Before 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

top

Before 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

top

Creates 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

top

Used 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

top

Creates a checkbox input widget.

Options:

  • value - the value of the checkbox
  • checked - 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

top

Used 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

top

Class constructor, overridden in descendant classes.

Method defined in:
cake/libs/object.php on line 54

create

top

Returns an HTML FORM element.

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 in conjunction with 'default' to create ajax forms.
  • inputDefaults set the default $options for FormHelper::input(). Any options that would be set when using FormHelper::input() can be set here. Options set with inputDefaults can be overridden when calling input()
  • encoding Set the accept-charset encoding for the form. Defaults to Configure::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

top

Returns a set of SELECT elements for a full datetime setup: day, month and year, and then time.

Attributes:

  • monthNames If false, 2 digit numbers will be used instead of text. If a array, the given array will be used.
  • 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 '-'
  • 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

top

Returns 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

top

Calls 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

top

Generates 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

top

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. 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

top

Returns a formatted error message for given FORM field, NULL if no errors.

Options:

  • 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

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, attributes key

  • 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

top

Extracts 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

top

Gets 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

top

Creates 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__

top

Default overload methods

Parameters:
  • $name required

Method defined in:
cake/libs/view/helper.php on line 151
Access

protected

hidden

top

Creates 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

top

Returns 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

top

Sets 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

top

Generates 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 - Either false to 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, select
  • error - control the error message that is produced
  • empty - 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

top

Generate 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

top

Generate 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

top

Introspects 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

top

Returns 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

top

Returns 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

top

Returns 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

top

Parses 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

top

Convience 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

top

Returns 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

top

Returns 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

top

Gets the currently-used model of the rendering context.

Method defined in:
cake/libs/view/helper.php on line 524
Return

string

Access

public

modelID

top

Gets 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

top

Returns 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

top

Gets 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

top

A 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

top

Returns 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

top

Overload implementation. No need for implementation in PHP5.

Method defined in:
cake/libs/overloadable_php5.php on line 36
Access

public

_parseAttributes

top

Returns 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

top

Creates 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

top

Checks 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

top

Creates 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 buttons
  • legend - control whether or not the widget set has a fieldset & legend
  • value - indicate a value that is should be checked
  • label - boolean to indicate whether or not labels for widgets show be displayed
  • hiddenField - 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

top

Calls 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

top

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 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

top

Generates 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

top

Returns 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

top

Allows 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__

top

Parameters:
  • $name required

  • $value required

Method defined in:
cake/libs/view/helper.php on line 152

setEntity

top

Sets 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

top

Stop 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

top

Creates 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

top

Returns 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

top

Creates 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

top

Creates 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

top

Object-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

top

Finds 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/23 or 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

top

Gets 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

top

Checks 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

top

Returns 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