From ffce710e4a721cbd18e1e061ec20945d81d9e47f Mon Sep 17 00:00:00 2001 From: Sam DeVore Date: Thu, 8 Jun 2017 15:05:30 -0700 Subject: [PATCH 1/2] Update Validation Errors section for 3.4.0 deprecation change to use getError, getErrors, setError, setErrors --- en/orm/entities.rst | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/en/orm/entities.rst b/en/orm/entities.rst index 1f309f2235..08bc8763bc 100644 --- a/en/orm/entities.rst +++ b/en/orm/entities.rst @@ -254,17 +254,25 @@ Validation Errors After you :ref:`save an entity ` any validation errors will be stored on the entity itself. You can access any validation errors using the -``errors()`` method:: +``getErrors()`` or ``getError()`` method:: // Get all the errors + $errors = $user->getErrors(); + // Prior to 3.4.0 $errors = $user->errors(); // Get the errors for a single field. + + $errors = $user->getError('password'); + // Prior to 3.4.0 $errors = $user->errors('password'); -The ``errors()`` method can also be used to set the errors on an entity, making +The ``setErrors()`` or ``setError()`` method can also be used to set the errors on an entity, making it easier to test code that works with error messages:: + $user->setError('password',['Password is required']); + $user->setErrors(['pasword'=>['Password is required'],'username'=>['Username is required']]); + // Prior to 3.4.0 $user->errors('password', ['Password is required.']); .. _entities-mass-assignment: From 3c2bf439375a175b52a60880c8cf07ce29042fdd Mon Sep 17 00:00:00 2001 From: Sam DeVore Date: Fri, 9 Jun 2017 10:49:12 -0700 Subject: [PATCH 2/2] Update for coding style issues --- en/orm/entities.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/en/orm/entities.rst b/en/orm/entities.rst index 08bc8763bc..dd09ad54c6 100644 --- a/en/orm/entities.rst +++ b/en/orm/entities.rst @@ -270,8 +270,8 @@ stored on the entity itself. You can access any validation errors using the The ``setErrors()`` or ``setError()`` method can also be used to set the errors on an entity, making it easier to test code that works with error messages:: - $user->setError('password',['Password is required']); - $user->setErrors(['pasword'=>['Password is required'],'username'=>['Username is required']]); + $user->setError('password', ['Password is required']); + $user->setErrors(['pasword' => ['Password is required'], 'username' => ['Username is required']]); // Prior to 3.4.0 $user->errors('password', ['Password is required.']);