Monday, July 28, 2014

CakePHP 3.0 Validation ?

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 cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: