$_request
$_request : \Cake\Http\ServerRequest
The request object.
Provides a basic array based context provider for FormHelper.
This adapter is useful in testing or when you have forms backed by simple array data structures.
Important keys:
defaults
The default values for fields. These values
will be used when there is no request data set. Data should be nested following
the dot separated paths you access your fields with.required
A nested array of fields, relationships and boolean
flags to indicate a field is required. The value can also be a string to be used
as the required error messageschema
An array of data that emulate the column structures that
Cake\Database\Schema\Schema uses. This array allows you to control
the inferred type for fields and allows auto generation of attributes
like maxlength, step and other HTML attributes. If you want
primary key/id detection to work. Make sure you have provided a _constraints
array that contains primary
. See below for an example.errors
An array of validation errors. Errors should be nested following
the dot separated paths you access your fields with.
$data = [
'schema' => [
'id' => ['type' => 'integer'],
'title' => ['type' => 'string', 'length' => 255],
'_constraints' => [
'primary' => ['type' => 'primary', 'columns' => ['id']]
]
],
'defaults' => [
'id' => 1,
'title' => 'First post!',
],
'required' => [
'id' => true, // will use default required message
'title' => 'Please enter a title',
'body' => false,
],
];
$_request : \Cake\Http\ServerRequest
The request object.
__construct(\Cake\Http\ServerRequest $request, array $context)
Constructor.
\Cake\Http\ServerRequest | $request | The request object. |
array | $context | Context info. |
val(string $field, array $options = array()) : mixed
Get the current value for a given field.
This method will coalesce the current request data and the 'defaults' array.
string | $field | A dot separated path to the field a value is needed for. |
array | $options | Options:
|
Loading…