Sunday, April 3, 2011

Re: 1 form 2 models - how to validate without savingAll?

yeah...
a quick overview over the cake "model.php" in "cake/libs/model/
model.php" shows me, that

---------------------------
if ($this->ModelName->saveAll($this->data, array('validate' =>
'only'))) {..
---------------------------

Does exactly the same as the code provided in the blog post.
It only validates one model after the other. I may be mistaken,
because i don't want to read each and every line of the code now, but
i'm pretty sure it is the same.

Also if you really want to do this:
----------------------------
if ($this->User->validates() && $this->Profile->validates()) {
----------------------------
it is the right method.

If you want to do that:
----------------------------
if ($this->User->validates()){...
//saving the user
//manipulating some data and stuff for the profile
if($this->Profile->validates()){...
----------------------------
The blog method is the right one.

Good Luck with your project ;)

On Apr 2, 6:01 pm, netusco <ernestcon...@gmail.com> wrote:
> Hi func0der,
>
> don't take it bad but I think you didn't read well my post, neither the
> title...
>
> I ask how to do it without savingAll, as I wanted to validate data in
> diferent steps and save at the end.
>
> Then as euromark pointed out in his blog the if statements check the first
> element and if it doesn't pass don't check the second so your solution
> behaves exactly the way I was doing it.
>
> Yet the solution found by euromark is smart and works perfectly.
>
> Thanks though to try to help even further, in this post is not needed but
> that's a great attitude.
>
> keep it up!

--
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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate