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.

Add to or get the list of fields that are currently unlocked. Unlocked fields are not included in the field hash used by SecurityComponent unlocking a field once its been added to the list of secured fields will remove it from the list of fields.

Parameters

Returns

Form context types allow FormHelper to interact with data providers that come from outside CakePHP. For example if you wanted to use an alternative ORM like Doctrine you could create and connect a new context class to allow FormHelper to read metadata from doctrine.

Parameters

string $type

The type of context. This key can be used to overwrite existing providers.

callable $check

A callable that returns an object when the form context is the correct type.

Generate a set of controls for $fields. If $fields is empty the fields of current model will be used.

You can customize individual controls through $fields.

$this->Form->allControls([
'name' => ['label' => 'custom label']
]);

You can exclude fields by specifying them as false:

$this->Form->allControls(['title' => false]);

In the above example, no field would be generated for the title field.

Parameters

array $fieldsoptional []

An array of customizations for the fields that will be generated. This array allows you to set custom types, labels, or other options.

array $optionsoptional []

Options array. Valid keys are: - fieldset Set to false to disable the fieldset. You can also pass an array of params to be applied as HTML attributes to the fieldset tag. If you pass an empty array, the fieldset will be enabled - legend Set to false to disable the legend for the generated control set. Or supply a string to customize the legend text.

Returns

Link

Generate a set of controls for $fields. If $fields is empty the fields of current model will be used.

Deprecated

3.4.0 Use FormHelper::allControls() instead.

Parameters

array $fieldsoptional []

An array of customizations for the fields that will be generated. This array allows you to set custom types, labels, or other options.

array $optionsoptional []

Options array. Valid keys are: - fieldset Set to false to disable the fieldset. You can also pass an array of params to be applied as HTML attributes to the fieldset tag. If you pass an empty array, the fieldset will be enabled - legend Set to false to disable the legend for the generated control set. Or supply a string to customize the legend text.

Returns

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(). Additionally, any unknown keys that are not in the list below, or part of the selected type's options will be treated as a regular HTML attribute for the generated 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().

options - For widgets that take options e.g. radio, select.

error - Control the error message that is produced. Set to false to disable any kind of error reporting (field error and error messages).

empty - String or boolean to enable empty select box options.

nestedInput - Used with checkbox and radio inputs. Set to false to render inputs outside of label elements. Can be set to true on any input to force the input inside the label. If you enable this option for radio buttons you will also need to modify the default radioWrapper template.

templates - The templates you want to use for this input. Any templates will be merged on top of the already loaded templates. This option can either be a filename in /config that contains the templates you want to load, or an array of templates to use.

labelOptions - Either false to disable label around nestedWidgets e.g. radio, multicheckbox or an array of attributes for the label tag. selected will be added to any classes e.g. class => 'myclass' where widget is checked

Parameters

array $fields

An array of the fields to generate. This array allows you to set custom types, labels, or other options.

array $optionsoptional []

Options array. Valid keys are: - fieldset Set to false to disable the fieldset. You can also pass an array of params to be applied as HTML attributes to the fieldset tag. If you pass an empty array, the fieldset will be enabled. - legend Set to false to disable the legend for the generated input set. Or supply a string to customize the legend text.

Link

Options:

type Form method defaults to autodetecting based on the form context. If the form context's isCreate() method returns false, a PUT request will be done.

method Set the form's method attribute explicitly.

action The controller action the form submits to, (optional). Use this option if you don't need to change the controller from the current request's controller. Deprecated since 3.2, use url.

url The URL the form submits to. Can be a string or a URL array. If you use 'url' you should leave 'action' undefined.

encoding Set the accept-charset encoding for the form. Defaults to Configure::read('App.encoding')

enctype Set the form encoding explicitly. By default type => file will set enctype to multipart/form-data.

templates The templates you want to use for this form. Any templates will be merged on top of the already loaded templates. This option can either be a filename in /config that contains the templates you want to load, or an array of templates to use.

context Additional options for the context class. For example the EntityContext accepts a 'table' option that allows you to set the specific Table class the form should be based on.

idPrefix Prefix for generated ID attributes.

valueSources The sources that values should be read from. See FormHelper::setValueSources()

templateVars Provide template variables for the formStart template.

Parameters

mixed $contextoptionalnull

The context for which the form is being defined. Can be a ContextInterface instance, ORM entity, ORM resultset, or an array of meta data. You can use false or null to make a context-less form.

Link

Parameters

string $fieldsoptional''

the form inputs to wrap in a fieldset

array $optionsoptional []

Options array. Valid keys are: - fieldset Set to false to disable the fieldset. You can also pass an array of params to be applied as HTML attributes to the fieldset tag. If you pass an empty array, the fieldset will be enabled - legend Set to false to disable the legend for the generated input set. Or supply a string to customize the legend text.

Deprecated

3.4.0 Use FormHelper::controls() instead.

Parameters

array $fields

An array of the fields to generate. This array allows you to set custom types, labels, or other options.

array $optionsoptional []

Options array. Valid keys are: - fieldset Set to false to disable the fieldset. You can also pass an array of params to be applied as HTML attributes to the fieldset tag. If you pass an empty array, the fieldset will be enabled. - legend Set to false to disable the legend for the generated input set. Or supply a string to customize the legend text.

Link

Creates an HTML link, but access the URL using the method you specify (defaults to POST). Requires javascript to be enabled in browser.

This method creates a <form> element. If you want to use this method inside of an existing form, you must use the block option so that the new form is being set to a view block that can be rendered outside of the main form.

If all you are looking for is a button to submit your form, then you should use FormHelper::button() or FormHelper::submit() instead.

Parameters

Returns

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

type - Set to 'reset' for reset inputs. Defaults to 'submit'

templateVars - Additional template variables for the input element and its container.

Other attributes will be assigned to the input element.

Parameters

string|null $captionoptionalnull

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.

Returns

See

Add to or get the list of fields that are currently unlocked. Unlocked fields are not included in the field hash used by SecurityComponent unlocking a field once its been added to the list of secured fields will remove it from the list of fields.

Parameters

string|null $nameoptionalnull

The dot separated name for the field.

Returns

array|nullEither null, or the list of fields.

Link

This is a lower level method. For built-in widgets, you should be using methods like text, hidden, and radio. If you are using additional widgets you should use this method render the widget without the label or wrapping div.