Свойство | Type | Description | |
---|---|---|---|
$fields | array | List of fields created, used with secure forms. | |
$helpers | array | Other helpers used by FormHelper | |
$requestType | string | Defines the type of form being created. Set by FormHelper::create(). |
Свойство | Type | Description | |
---|---|---|---|
$_context | Cake\View\Form\ContextInterface | Context for the current form. | |
$_contextProviders | array | Context provider methods. | |
$_datetimeOptions | array | Special options used for datetime inputs. | |
$_datetimeParts | array | The various pickers that make up a datetime picker. | |
$_defaultConfig | array | Default config for the helper. | |
$_defaultWidgets | array | Default widgets | |
$_lastAction | string | Used to make form/request specific hashes for SecurityComponent. | |
$_registry | Cake\View\Widget\WidgetRegistry | Registry for input widgets. | |
$_unlockedFields | array | An array of field names that have been excluded from the Token hash used by SecurityComponent's validatePost method |
Méthode | Description | |
---|---|---|
__call ( string $method, array $params ) : string | Missing method handler - implements various simple input types. Is used to create inputs of various types. e.g. $this->Form->text(); will create while $this->Form->range(); will create | |
__construct ( Cake\View\View $View, array $config = [] ) | Construct the widgets and binds the default context providers | |
addContextProvider ( string $type, callable $check ) : void | Add a new context type. | |
addWidget ( string $name, array | Cake\View\Widget\WidgetInterface $spec ) : void | Add a new widget to FormHelper. | |
allInputs ( array $fields = [], array $options = [] ) : string | Generate a set of inputs for $fields. If $fields is empty the fields of current model will be used. | |
button ( string $title, array $options = [] ) : string | Creates a | |
checkbox ( string $fieldName, array $options = [] ) : string | array | Creates a checkbox input widget. | |
context ( Cake\View\Form\ContextInterface | null $context = null ) : null | Cake\View\Form\ContextInterface | Get the context instance for the current form set. | |
create ( mixed $model = null, array $options = [] ) : string | Returns an HTML FORM element. | |
date ( string $fieldName, array $options = [] ) : string | Generate date inputs. | |
dateTime ( string $fieldName, array $options = [] ) : string | Returns a set of SELECT elements for a full datetime setup: day, month and year, and then time. | |
day ( string | null $fieldName = null, array $options = [] ) : string | Returns a SELECT element for days. | |
end ( array $secureAttributes = [] ) : string | Closes an HTML form, cleans up values set by FormHelper::create(), and writes hidden input fields where appropriate. | |
error ( string $field, string | array | null $text = null, array $options = [] ) : string | Returns a formatted error message for given form field, '' if no errors. | |
fieldset ( string $fields = '', array $options = [] ) : string | Wrap a set of inputs in a fieldset | |
file ( string $fieldName, array $options = [] ) : string | Creates file input widget. | |
hidden ( string $fieldName, array $options = [] ) : string | Creates a hidden input field. | |
hour ( string $fieldName, array $options = [] ) : string | Returns a SELECT element for hours. | |
implementedEvents ( ) : array | Event listeners. | |
input ( string $fieldName, array $options = [] ) : string | Generates a form input element complete with label and wrapper div | |
inputs ( array $fields, array $options = [] ) : string | Generate a set of inputs for $fields wrapped in a fieldset element. | |
isFieldError ( string $field ) : boolean | Returns true if there is an error for the given field, otherwise false | |
label ( string $fieldName, string | null $text = null, array $options = [] ) : string | Returns a formatted LABEL element for HTML forms. | |
meridian ( string $fieldName, array $options = [] ) : string | Returns a SELECT element for AM or PM. | |
minute ( string $fieldName, array $options = [] ) : string | Returns a SELECT element for minutes. | |
month ( string $fieldName, array $options = [] ) : string | Returns a SELECT element for months. | |
multiCheckbox ( string $fieldName, array | Traversable $options, array $attributes = [] ) : string | Creates a set of checkboxes out of options. | |
postButton ( string $title, string | array $url, array $options = [] ) : string | Create a | |
postLink ( string $title, string | array | null $url = null, array $options = [] ) : string | Creates an HTML link, but access the URL using the method you specify (defaults to POST). Requires javascript to be enabled in browser. | |
radio ( string $fieldName, array | Traversable $options = [], array $attributes = [] ) : string | Creates a set of radio widgets. | |
resetTemplates ( ) : void | Restores the default values built into FormHelper. | |
secure ( array $fields = [], array $secureAttributes = [] ) : string | Generates a hidden field with a security hash based on the fields used in the form. | |
select ( string $fieldName, array | Traversable $options = [], array $attributes = [] ) : string | Returns a formatted SELECT element. | |
submit ( string | null $caption = null, array $options = [] ) : string | Creates a submit button element. This method will generate 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. | |
textarea ( string $fieldName, array $options = [] ) : string | Creates a textarea widget. | |
time ( string $fieldName, array $options = [] ) : string | Generate time inputs. | |
unlockField ( string | null $name = null ) : array | null | Add to or get the list of fields that are currently unlocked. | |
widget ( string $name, array $data = [] ) : string | Render a named widget. | |
widgetRegistry ( Cake\View\Widget\WidgetRegistry $instance = null, array $widgets = [] ) : Cake\View\Widget\WidgetRegistry | Set the widget registry the helper will use. | |
year ( string $fieldName, array $options = [] ) : string | Returns a SELECT element for years |
Méthode | Description | |
---|---|---|
_addDefaultContextProviders ( ) : void | Add the default suite of context providers provided by CakePHP. | |
_csrfField ( ) : string | Return a CSRF input if the request data is present. | |
_datetimeOptions ( array $options ) : array | Helper method for converting from FormHelper options data to widget format. | |
_extractOption ( string $name, array $options, mixed $default = null ) : mixed | Extracts a single option from an options array. | |
_formUrl ( Cake\View\Form\ContextInterface $context, array $options ) : string | Create the URL for a form based on the options. | |
_getContext ( mixed $data = [] ) : mixed | Find the matching context provider for the data. | |
_getInput ( string $fieldName, array $options ) : string | Generates an input element | |
_getLabel ( string $fieldName, array $options ) : boolean | string | Generate label for input | |
_groupTemplate ( array $options ) : string | Generates an group template element | |
_initInputField ( string $field, array $options = [] ) : array | Sets field defaults and adds field to form security input hash. | |
_inputContainerTemplate ( array $options ) : string | Generates an input container template | |
_inputLabel ( string $fieldName, string $label, array $options ) : string | Generate a label for an input() call. | |
_inputType ( string $fieldName, array $options ) : string | Returns the input type that was guessed for the provided fieldName, based on the internal type it is associated too, its name and the variables that can be found in the view template | |
_isRequiredField ( Cake\Validation\ValidationSet $validationRules ) : boolean | Returns if a field is required to be filled based on validation properties from the validating object. | |
_lastAction ( string | array $url ) : void | Correctly store the last created form action URL. | |
_magicOptions ( string $fieldName, array $options, boolean $allowOverride ) : array | Magically set option type and corresponding options | |
_optionsOptions ( string $fieldName, array $options ) : array | Selects the variable containing the options for a select field if present, and sets the value to the 'options' key in the options array. | |
_parseOptions ( string $fieldName, array $options ) : array | Generates input options array | |
_secure ( boolean $lock, string | array $field, mixed $value = null ) : void | Determine which fields of a form should be used for hash. | |
_secureFieldName ( string $name ) : array | Get the field name for use with _secure(). | |
_singleDatetime ( array $options, string $keep ) : array | Helper method for the various single datetime component methods. |
public __construct ( Cake\View\View $View, array $config = [] ) | ||
$View | Cake\View\View | The View this helper is being attached to. |
$config | array | Configuration settings for the helper. |
protected _addDefaultContextProviders ( ) : void | ||
Résultat | void |
protected _csrfField ( ) : string | ||
Résultat | string |
protected _datetimeOptions ( array $options ) : array | ||
$options | array | Options to convert. |
Résultat | array | Converted options. |
protected _getContext ( mixed $data = [] ) : mixed | ||
$data | mixed | The data to get a context provider for. |
Résultat | mixed | Context provider. |
protected _groupTemplate ( array $options ) : string | ||
$options | array | The options for group template |
Résultat | string | The generated group template |
protected _inputContainerTemplate ( array $options ) : string | ||
$options | array | The options for input container template |
Résultat | string | The generated input container template |
protected _isRequiredField ( Cake\Validation\ValidationSet $validationRules ) : boolean | ||
$validationRules | Cake\Validation\ValidationSet | Validation rules set. |
Résultat | boolean | true if field is required to be filled, false otherwise |
protected _magicOptions ( string $fieldName, array $options, boolean $allowOverride ) : array | ||
$fieldName | string | The name of the field to generate options for. |
$options | array | Options list. |
$allowOverride | boolean | Whether or not it is allowed for this method to overwrite the 'type' key in options. |
Résultat | array |
protected _secure ( boolean $lock, string | array $field, mixed $value = null ) : void | ||
$lock | boolean | Whether this field should be part of the validation or excluded as part of the unlockedFields. |
$field | string | array | Reference to field to be secured. Can be dot separated string to indicate nesting or array of fieldname parts. |
$value | mixed | Field value, if value should not be tampered with. |
Résultat | void |
protected _secureFieldName ( string $name ) : array | ||
$name | string | The form inputs name attribute. |
Résultat | array | Array of field name params like ['Model.field'] or ['Model', 'field'] for array fields or empty array if $name is empty. |
public allInputs ( array $fields = [], array $options = [] ) : string | ||
$fields | array | An array of customizations for the fields that will be generated. This array allows you to set custom types, labels, or other options. |
$options | array | 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. |
Résultat | string | Completed form inputs. |
public create ( mixed $model = null, array $options = [] ) : string | ||
$model | mixed | The context for which the form is being defined. Can be an ORM entity, ORM resultset, or an array of meta data. You can use false or null to make a model-less form. |
$options | array | An array of html attributes and options. |
Résultat | string | An formatted opening FORM tag. |
public error ( string $field, string | array | null $text = null, array $options = [] ) : string | ||
$field | string | A field name, like "modelname.fieldname" |
$text | string | array | null | Error message as string or array of messages. If an array, it should be a hash of key names => messages. |
$options | array | See above. |
Résultat | string | Formatted errors or ''. |
public fieldset ( string $fields = '', array $options = [] ) : string | ||
$fields | string | the form inputs to wrap in a fieldset |
$options | array | 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. |
Résultat | string | Completed form inputs. |
public implementedEvents ( ) : array | ||
Résultat | array |
public inputs ( array $fields, array $options = [] ) : string | ||
$fields | array | An array of the fields to generate. This array allows you to set custom types, labels, or other options. |
$options | array | 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. |
Résultat | string | Completed form inputs. |
public isFieldError ( string $field ) : boolean | ||
$field | string | This should be "modelname.fieldname" |
Résultat | boolean | If there are errors this method returns true, else false. |
public label ( string $fieldName, string | null $text = null, array $options = [] ) : string | ||
$fieldName | string | This should be "modelname.fieldname" |
$text | string | null | Text that will appear in the label field. If $text is left undefined the text will be inflected from the fieldName. |
$options | array | An array of HTML attributes. |
Résultat | string | The formatted LABEL element |
public multiCheckbox ( string $fieldName, array | Traversable $options, array $attributes = [] ) : string | ||
$fieldName | string | Name attribute of the SELECT |
$options | array | Traversable | Array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the checkboxes element. |
$attributes | array | The HTML attributes of the select element. |
Résultat | string | Formatted SELECT element |
public postLink ( string $title, string | array | null $url = null, array $options = [] ) : string | ||
$title | string | The content to be wrapped by tags. |
$url | string | array | null | Cake-relative URL or array of URL parameters, or external URL (starts with http://) |
$options | array | Array of HTML attributes. |
Résultat | string | An `` element. |
public radio ( string $fieldName, array | Traversable $options = [], array $attributes = [] ) : string | ||
$fieldName | string | Name of a field, like this "modelname.fieldname" |
$options | array | Traversable | Radio button options array. |
$attributes | array | Array of attributes. |
Résultat | string | Completed radio widget set. |
public resetTemplates ( ) : void | ||
Résultat | void |
public secure ( array $fields = [], array $secureAttributes = [] ) : string | ||
$fields | array | If set specifies the list of fields to use when generating the hash, else $this->fields is being used. |
$secureAttributes | array | will be passed as HTML attributes into the hidden input elements generated for the Security Component. |
Résultat | string | A hidden input field with a security hash, or empty string when secured forms are not in use. |
public select ( string $fieldName, array | Traversable $options = [], array $attributes = [] ) : string | ||
$fieldName | string | Name attribute of the SELECT |
$options | array | Traversable | Array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the SELECT element |
$attributes | array | The HTML attributes of the select element. |
Résultat | string | Formatted SELECT element |
public submit ( string | null $caption = null, array $options = [] ) : string | ||
$caption | string | 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. |
$options | array | Array of options. See above. |
Résultat | string | A HTML submit button |
public widgetRegistry ( Cake\View\Widget\WidgetRegistry $instance = null, array $widgets = [] ) : Cake\View\Widget\WidgetRegistry | ||
$instance | Cake\View\Widget\WidgetRegistry | The registry instance to set. |
$widgets | array | An array of widgets |
Résultat | Cake\View\Widget\WidgetRegistry |
protected ContextInterface,Cake\View\Form $_context | ||
Résultat | Cake\View\Form\ContextInterface |
protected array $_contextProviders | ||
Résultat | array |
protected array $_datetimeOptions | ||
Résultat | array |
protected array $_datetimeParts | ||
Résultat | array |
protected array $_defaultConfig | ||
Résultat | array |
protected array $_defaultWidgets | ||
Résultat | array |
protected string $_lastAction | ||
Résultat | string |
protected WidgetRegistry,Cake\View\Widget $_registry | ||
Résultat | Cake\View\Widget\WidgetRegistry |
protected array $_unlockedFields | ||
Résultat | array |
public array $fields | ||
Résultat | array |
public string $requestType | ||
Résultat | string |