Sunday, January 4, 2009

Re: Edit multiple models in the same page: possible?

All you need to do is handle the related models in the same form.
There's no need to separate into two forms unless that's your
intention. I have many pages where I update data from one form into
multiple models (e.g. - register a user and sign him up for a job,
which involves creating a row in users, and then updating the HABTM
for jobs).

The form create action can be used to tell it which controller and
action to submit as well, so you could have something like:

<?php echo $form->create('Image', array('controller' =>
'profiles', 'action' => 'image' ));?>

To submit the form to the 'image' action of the 'profiles' controller.

The redirection you're talking about is controlled by the action of
the form, so if you want it to go somewhere else, you just need to
code things that way.


On Jan 3, 4:07 pm, Jaime <ja...@iteisa.com> wrote:
> Hi all,
>
> I wonder if it's possible to have two different forms for two
> different (but related) models in the same page.
>
> Imagine a page where the logged in user can edit his profile (model
> Profile) as well as to add a photo into his gallery (model Image).
>
> <?php echo $form->create('Profile'); ?>
> ...
>
> <?php echo $form->create('Image'); ?>
> ...
>
> The problem here is that after submiting one of the forms, the user is
> redirected to /model/edit/, and not back to the current page.
>
> I cannot imagine how to fit both forms in the same page without
> loosing the validationErrors info.
>
> Any clue?
--~--~---------~--~----~------------~-------~--~----~
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: