A few questions:
- Where did you put DevoirsTable ?
- How did you name the DevoirsTable file?
- What namespace did you use in that file?
- Can you verify that file is being included?
And a small correction, This is not needed in a DevoirsController:
$this->Devoirs = TableRegistry::get('Devoirs');
On Monday, July 28, 2014 10:20:06 PM UTC+2, Mikaël Capelle wrote:
>
> Hi everyone,
>
> I'm trying to build a new CakePHP 3 application but I didn't manage to get
> the data validation working... I followed the CakePHP 3.0 book, and
> particulary this page
> http://book.cakephp.org/3.0/en/tutorials-and-examples/blog/part-two.html
> but it didn't help.
>
> Currently, my Table is as follow:
>
> class DevoirsTable extends Table {
>
> public function initialize(array $config) {
>
> }
>
> public function validationDefault (Validator $validator) {
> debug('TEST HERE') ;
> $validator->notEmpty('pseudo', 'Oh my god!');
> return $validator;
> }
> }
>
>
> And my controller:
>
> $this->Devoirs = TableRegistry::get('Devoirs') ;
> $devoir = $this->Devoirs->find()->first() ;
> if ($this->request->is(['post', 'put'])) {
> $this->Devoirs->patchEntity($devoir, $this->request->data) ;
> $this->set('saved', $this->Devoirs->save($devoir, ['validate' =>
> true])) ;
> }
>
>
> This is only a test action, the row is correctly updated in my database
> but the 'TEST HERE' string never showed up... I don't understand how the
> new validation system works, maybe someone can help me?
>
> Thanks,
>
>
--
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.