Interface for FormHelper context implementations.
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:
data Holds the current values supplied for the fields.defaults The default values for fields. These values
will be used when there is no 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
{@link \Cake\Database\Schema\TableSchema} 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. $article = [
'data' => [
'id' => '1',
'title' => 'First post!',
],
'schema' => [
'id' => ['type' => 'integer'],
'title' => ['type' => 'string', 'length' => 255],
'_constraints' => [
'primary' => ['type' => 'primary', 'columns' => ['id']]
]
],
'defaults' => [
'title' => 'Default title',
],
'required' => [
'id' => true, // will use default required message
'title' => 'Please enter a title',
'body' => false,
],
];
Factory for getting form context instance based on provided data.
Provides a form context around a single entity and its relations. It also can be used as context around an array or iterator of entities.
This class lets FormHelper interface with entities or collections of entities.
Important Keys:
entity The entity this context is operating on.table Either the ORM\Table instance to fetch schema/validators
from, an array of table instances in the case of a form spanning
multiple entities, or the name(s) of the table.
If this is null the table name(s) will be determined using naming
conventions.validator Either the Validation\Validator to use, or the name of the
validation method to call on the table object. For example 'default'.
Defaults to 'default'. Can be an array of table alias=>validators when
dealing with associated forms.Provides a context provider for {@link \Cake\Form\Form} instances.
This context provider simply fulfils the interface requirements that FormHelper has and allows access to the form data.
Provides a context provider that does nothing.
This context provider simply fulfils the interface requirements that FormHelper has.