Tuesday, April 28, 2009

Re: Validate in Controller

Have a look at this post from Teknoid:

http://teknoid.wordpress.com/2008/10/16/how-to-validate-habtm-data/

On Tue, Apr 28, 2009 at 7:46 PM, Dave Maharaj :: WidePixels.com
<dave@widepixels.com> wrote:
>
> Trying to validate in controller before saving with this:
>
> $this->User->$model_name->set($this->data);
>                      debug($this->data);
>                      if ($this->User->$model_name->validates()) {
>                          debug($model_name);
>                          $test = 'Validated';
>                          debug($test);
>                      } else {
>                          $test = 'Not Validated';
>                          debug($test);
>                      }
>
> debug data:
> Array
> (
>    [System] => Array
>        (
>            [System] => Array
>                (
>                    [0] => abc <- manually entered with FireBug
>                    [1] => 1
>                )
>
>        )
>
> )
>
>
> but it always comes back valid. Testing using one model where $model_name is
> System and that model has validate 'system_id' => array('numeric')
>
> Where am I going wrong?
>
> Thanks,
>
> Dave
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: