Re: Forms that add/edit Multiple Models part II

2008-04-24 Thread Jee

Sorry about that.  I am never sure how much to include!

Following is the action the form posts to.  I have validation rules in
both the Agency model and the Member model.
But the validation errors from the member model don't show up on a
failure. Only the agency errors show and not all of those.

What I have here doesn't seem very DRY to me, but usually once I get
it working I can clean it up.
Another issue I noted was that I have to explicitly remove the agency
data if the member save doesn't work.  Seems like it should be tied
together more tightly.

I am currently trying the saveAll you suggested.
Thanks for any suggestions!

Jee
=
data)) {
$this->Agency->Member->validate($this->data["Member"]);
$this->Agency->validate($this->data["Agency"]);
  $this->Agency->Member->create();
  $this->Agency->create();
if ($this->Agency->save($this->data["Agency"])) :
  if ($this->Agency->Member->save($this->data["Member"])) :
$this->Session->setFlash(__('Thank you for 
joining us!  Your
new account has been saved', true));

$this->redirect(array('url'=>'/files/signup.pdf'));
else :
  $this->Agency->remove();
  $this->Session->setFlash(__('We are sorry but 
your new account
could not be saved. Please, check the Contact Details for errors and
try again.', true));
  endif;
else :
$this->Session->setFlash(__('We are sorry but 
your new account
could not be saved. Please, check the Agency Details for errors and
try again.', true));
endif;
}
$referrals = $this->Agency->Referral->find('list');
$this->set(compact('referrals'));
  }
}
?>
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Forms that add/edit Multiple Models part II

2008-04-23 Thread Dr. Tarique Sani
On Thu, Apr 24, 2008 at 2:05 AM, Jee <[EMAIL PROTECTED]> wrote:

>
> Can anyone give me any suggestions for adding and editing multiple
> models from one form in Cake 1.2?


A call to saveAll should  suffice

but it would also help if you showed some code that you are using

Tarique

-- 
=
Cheesecake-Photoblog: http://cheesecake-photoblog.org
PHP for E-Biz: http://sanisoft.com
=

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Forms that add/edit Multiple Models part II

2008-04-23 Thread Jee

Can anyone give me any suggestions for adding and editing multiple
models from one form in Cake 1.2?

I found a post on the topic here:
http://groups.google.com/group/cake-php/browse_thread/thread/77183ca04771e348
but I get the following when I attempted it:
===
Warning (512): (Model::validates) Parameter usage is deprecated, use
Model::set() to update your fields first [CORE/cake/libs/model/
model.php, line 2018]

Warning (512): (Model::invalidFields) Parameter usage is deprecated,
set the $data property instead [CORE/cake/libs/model/model.php, line
2051]

Following the first logical step, I replaced validates() with set()
which cleared up the Warnings, but did not actually validate the
fields.
I wish I knew enough about cake to even come up with a second logical
step!  :)

Suggestions?
Thanks,
Jee
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---