Свойство | Type | Description | |
---|---|---|---|
$DEFAULT_ERROR_MESSAGES |
Méthode | Description | |
---|---|---|
__construct ( ActiveRecord\Model $model ) : |
Constructs an {@link Errors} object. | |
__get ( string $attribute ) : array | Retrieve error messages for an attribute. | |
__toString ( ) : string | Convert all error messages to a String. | |
add ( string $attribute, string $msg ) | Add an error message. | |
add_on_blank ( string $attribute, string $msg ) | Adds the error message only if the attribute value was null or an empty string. | |
add_on_empty ( string $attribute, string $msg ) | Adds an error message only if the attribute value is {@link http://www.php.net/empty empty}. | |
clear ( ) | Clears out all error messages. | |
clear_model ( ) | Nulls $model so we don't get pesky circular references. $model is only needed during the validation process and so can be safely cleared once that is done. | |
full_messages ( ) : array | Returns all the error messages as an array. | |
getIterator ( ) : ArrayIterator | Returns an iterator to the error messages. | |
get_raw_errors ( ) | Returns the internal errors object. | |
is_empty ( ) : boolean | Returns true if there are no error messages. | |
is_invalid ( string $attribute ) : boolean | Returns true if the specified attribute had any error messages. | |
on ( string $attribute ) : string/array | Returns the error message(s) for the specified attribute or null if none. | |
size ( ) : integer | Returns the number of error messages there are. | |
to_array ( callable $closure = null ) : array | Returns all the error messages as an array, including error key. |
public __construct ( ActiveRecord\Model $model ) : |
||
$model | ActiveRecord\Model | The model the error is for |
Résultat |
echo $error;
# "Name can't be blank\nState is the wrong length (should be 2 chars)"
public __toString ( ) : string | ||
Résultat | string |
public add_on_blank ( string $attribute, string $msg ) | ||
$attribute | string | Name of an attribute on the model |
$msg | string | The error message |
public add_on_empty ( string $attribute, string $msg ) | ||
$attribute | string | Name of an attribute on the model |
$msg | string | The error message |
public clear_model ( ) |
$model->errors->full_messages();
# array(
# "Name can't be blank",
# "State is the wrong length (should be 2 chars)"
# )
public full_messages ( ) : array | ||
Résultat | array |
foreach ($model->errors as $msg)
echo "$msg\n";
public getIterator ( ) : ArrayIterator | ||
Résultat | ArrayIterator |
$model->errors->get_raw_errors();
# array(
# "name" => array("can't be blank"),
# "state" => array("is the wrong length (should be 2 chars)",
# )
public get_raw_errors ( ) |
public is_invalid ( string $attribute ) : boolean | ||
$attribute | string | Name of an attribute on the model |
Résultat | boolean |
$model->errors->errors();
# array(
# "name" => array("Name can't be blank"),
# "state" => array("State is the wrong length (should be 2 chars)")
# )