On Dec 27, 9:59 am, RhythmicDevil <rhythmicde...@gmail.com> wrote:
> Hi all,
> I am trying to get validation working for my application but I am
> getting some weirdness. I have setup a custom RBAC implementation
> using MongoDB and Ichikaway's datasource.
>
> https://github.com/ichikaway/mongoDB-Datasource
>
> I am working on validating in the Groups Model. This is my validate
> property:
>
> public $validate = array(
> 'group' => array(
> 'isUnique' => array(
> 'rule' => 'isUnique',
> 'required' => true,
> 'message' => 'Duplicate Group',
> ),
> 'notEmpty' => array(
> 'rule' => 'notEmpty',
> 'required' => true,
> 'message' => 'Group name is required',
> )
> )
> );
>
> And I also have a validates() method
>
> public function validates()
> {
> parent::validates();
>
> var_dump($this);
> }
>
> So a couple of different scenarios give different results but not the
> one I need.
>
> 1. If I wrap the Group->save() call in the controller like this:
>
> if ($this->Group->validates())
> {
> if ($this->Group->save($this->data))
> {
> $this->flash(__('Group Created.', true),
> array('action' => 'index'));
> }
> }
>
> I always get a validation error when I edit saying that the group name
> must be unique.
>
> 2. If I dont wrap the save method in the controller and only supply
> the Model::validate property and the Model::validates() method then
> the validation works but there is no notification. I have dumped out
> the contents of the Model but I cant see anything that I can use to
> determine what validation failed.
>
> 3. If I remove the Model::validates() method the Model acts like the
> record saves but does not actually update the record. In other words
> the record does not change unless the new data does not violate any of
> the validation rules.
>
> Ok so I am out in the weeds. I realize I have to do some coding to
> make this work, but I am not sure where that code should go. Does the
> Datasource have something to do with filling the validation errors
> array?
>
> What I really want it to make sure that the validation errors array
> gets something so I can determine what happened and inform the user.
>
> Thanks
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment