Result
in package
Holds the result of a validation of a form
Table of Contents
- $doNothing : bool
- $errors : array<string|int, array<string|int, mixed>>
- $fields : array<string|int, Field>
- $hasErrors : bool
- $name : string|null
- __construct() : mixed
- Creates a new FormResult object
- addCustomError() : mixed
- Adds a custom error to the form result and sets hasErrors to true
- getValue() : mixed
- Gets a validated input value
Properties
$doNothing
public
bool
$doNothing
When set, no CED action will be performed when this object is given into one.
$errors
public
array<string|int, array<string|int, mixed>>
$errors
Holds the errors of the validation, each as an array with name, type and optionally info
$fields
public
array<string|int, Field>
$fields
Array of the validated fields.
$hasErrors
public
bool
$hasErrors
Set when the input data was invalid
$name
public
string|null
$name
Holds the name of a form result. Used for CED forms; uninitialized unless set by validateCED()
Methods
__construct()
Creates a new FormResult object
public
__construct() : mixed
Return values
mixed —addCustomError()
Adds a custom error to the form result and sets hasErrors to true
public
addCustomError(string $name, string $type) : mixed
Parameters
- $name : string
-
Name of the form field to assign the error to
- $type : string
-
Type of the error, e.g. filter, unique, required or in. Z.js maps it to the message Z.Lang["error_" . $type]
Return values
mixed —getValue()
Gets a validated input value
public
getValue(string $name) : mixed
Parameters
- $name : string
-
Name of the field to get the value from
Return values
mixed —The validated value (rule-cast, array for multi-select), or null when the field is unknown or its input was empty