Tarique, I recently pushed some changes to the validation. You can now do:
$validator->allowEmpty('my_field', false, 'My Custom message');
This deprecates the use of the 'notEmpty' rule.
On Friday, March 14, 2014 12:55:58 PM UTC+1, Dr. Tarique Sani wrote:
>
> Thanks a lot José, would be interesting to compare what you do with what I
> was going to do :)
>
> Cheers
> Tarique
>
>
> On Fri, Mar 14, 2014 at 3:07 PM, José Lorenzo <[email protected]<javascript:>
> > wrote:
>
>> Tarique, I can confirm the problem. It is actually an overlook on how the
>> validation system works now I will implementing a solution and providing
>> documentation for it soon.
>>
>>
>> On Friday, March 14, 2014 10:10:18 AM UTC+1, José Lorenzo wrote:
>>>
>>> Sure, I think github is a better place to track this problem
>>>
>>> On Friday, March 14, 2014 7:56:40 AM UTC+1, Dr. Tarique Sani wrote:
>>>>
>>>> Another strange thing. If I use an Entity class written in a file then
>>>> at least the validation works but if I try the following in the controller
>>>>
>>>> $article = new Cake\ORM\Entity;
>>>> $article->accessible('*', true);
>>>> $article = $this->Articles->patchEntity($article,
>>>> $this->request->data);
>>>>
>>>> Validation is completely skipped. I traced it till the
>>>> _addValidatorProps in http://api.cakephp.org/3.0/
>>>> source-class-Cake.Validation.ValidationRule.html#171-190 and then ran
>>>> out of time...
>>>>
>>>> Should I file this on github?
>>>>
>>>> Cheers
>>>>
>>>> Tarique
>>>>
>>>>
>>>>
>>>> On Fri, Mar 14, 2014 at 8:46 AM, Dr. Tarique Sani
>>>> <[email protected]>wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> Wonder if you had the time to look into why custom error messages
>>>>> don't get populated?
>>>>>
>>>>> http://bin.cakephp.org/saved/120670 has my complete Table class
>>>>>
>>>>> The controller is more or less like you suggested in
>>>>> http://bin.cakephp.org/saved/120567
>>>>>
>>>>> Cheers
>>>>> Tarique
>>>>>
>>>>>
>>>>> On Thu, Mar 13, 2014 at 1:56 PM, José Lorenzo <[email protected]>wrote:
>>>>>
>>>>>> It could be a bug. I'm going to check that out in a bit. To avoid the
>>>>>> strict warning you need:
>>>>>>
>>>>>> use Cake\Validation\Validator;
>>>>>>
>>>>>> class ArticlesTable extends Table {
>>>>>>
>>>>>> public function validationDefault(Validator $validator) {
>>>>>> ...
>>>>>>
>>>>>>
>>>>>> On Thursday, March 13, 2014 6:07:47 AM UTC+1, Dr. Tarique Sani wrote:
>>>>>>>
>>>>>>> My AtriclesTable has
>>>>>>>
>>>>>>>
>>>>>>> public function validationDefault($validator) {
>>>>>>> $validator
>>>>>>> ->add('title', 'not-Empty', [
>>>>>>> 'rule' => 'notEmpty',
>>>>>>> 'message' => 'You need to provide a title',
>>>>>>> ])
>>>>>>> ->add('body', 'not-Empty', [
>>>>>>> 'rule' => 'notEmpty',
>>>>>>> 'message' => 'A body is required'
>>>>>>> ]);
>>>>>>> return $validator;
>>>>>>> }
>>>>>>>
>>>>>>> When I try to save an article entity the validation runs fine but I
>>>>>>> am only getting the default in the ArticleEntity
>>>>>>>
>>>>>>> 'errors' => [
>>>>>>> 'title' => [
>>>>>>> (int) 0 => 'This field cannot be left empty'
>>>>>>> ],
>>>>>>> 'body' => [
>>>>>>> (int) 0 => 'This field cannot be left empty'
>>>>>>> ]
>>>>>>> ]
>>>>>>>
>>>>>>> Additionally there is a warning
>>>>>>>
>>>>>>> Strict (2048): Declaration of
>>>>>>> App\Model\Table\ArticlesTable::validationDefault()
>>>>>>> should be compatible with
>>>>>>> Cake\ORM\Table::validationDefault(Cake\Validation\Validator
>>>>>>> $validator) [APP/Model/Table/ArticlesTable.php, line 7]
>>>>>>>
>>>>>>> What additional steps are needed to fix this?
>>>>>>>
>>>>>>> Cheers
>>>>>>> Tarique
>>>>>>>
>>>>>>> --
>>>>>>> =============================================================
>>>>>>> The Conference Schedule Creator : http://shdlr.com
>>>>>>>
>>>>>>> PHP for E-Biz : http://sanisoft.com
>>>>>>> =============================================================
>>>>>>>
>>>>>> --
>>>>>> Like Us on FaceBook https://www.facebook.com/CakePHP
>>>>>> Find us on Twitter http://twitter.com/CakePHP
>>>>>>
>>>>>> ---
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "CakePHP" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> To post to this group, send email to [email protected].
>>>>>> Visit this group at http://groups.google.com/group/cake-php.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> =============================================================
>>>>> The Conference Schedule Creator : http://shdlr.com
>>>>>
>>>>> PHP for E-Biz : http://sanisoft.com
>>>>> =============================================================
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> =============================================================
>>>> The Conference Schedule Creator : http://shdlr.com
>>>>
>>>> PHP for E-Biz : http://sanisoft.com
>>>> =============================================================
>>>>
>>> --
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "CakePHP" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/cake-php.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> =============================================================
> The Conference Schedule Creator : http://shdlr.com
>
> PHP for E-Biz : http://sanisoft.com
> =============================================================
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.