Wednesday, June 23, 2010

Re: Data validtation

I notice a couple of things. Surely you model name should be InviteApply (note the capital i)? When you check if ($this->inviteApply-validates()) you will only get true or false. In fact, you don't need to check if it validates as that is part of the save function. Try this instead:

if (! $this->inviteApply->save($this->data)):
die(debug($this->inviteApply->validationErrors));
else:
//it saved OK - do something
endif;

Jeremy Burns
Class Outfit

jeremyburns@classoutfit.com
http://www.classoutfit.com

On 23 Jun 2010, at 17:26, Amit Kumar wrote:

> Hi! I am new to cakePHP, and have been trying to develop an
> application with it. While using cakePHP i created a model with these
> validation rules...
>
> var $validate = array(
> 'name' => array(
> 'rule'=>array('minLength', 1),
> 'message'=>'Name is required' ),
> 'email' => array(
> 'rule'=>'email',
> 'message'=>'Must be a valid email address' )
> );
>
> the controller goes as
>
>
> $this->inviteApply->set($this->data);
> if($this->inviteApply->validates())
> {
> $this->inviteApply->save($this->data);
> }
> else
> {
> die();
> }
>
> Nw with this, according to all docuemntin and examples.. the data
> should be validated and errors should be reported... nthng like that
> seems to be happening...
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> 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

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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: