I don't understand the problem at all.
If you have done no redirects you would get:
The action fu renders the view fu.
The view fu contains a form pointing to the action save.
The action save processes the form and renders the view save.
To have the action save "returning control" to edit of fu you would
have to have a redirect somewhere. (either explicitly or via $this-
>flash() )
Whenever I have an action like save (that does only the saving or
processing of other actions) I often just have:
public function save() {
$ret = $this->Message->save($this->data);
if ( $ret ) {
$this->Session->setFlash( ___('message_save_ok'), 'default',
array(), 'ok');
$this->redirect($this->referer());
} else {
$this->Session->setFlash( ___('message_save_err'), 'default',
array(), 'error');
$this->redirect('.');
}
}
If I was into flash instead of setFlash the logic would be a little
different.
Ignoring the message-flashing, what happens is: if save fails, go to
the index. If successful go back to where you were. When the action is
the primary save-function I will also check if this is a "new" save or
an update and add suitable logic to handle that. Sometimes you want to
go back to "add" to create the next item. Sometimes you want to go to
edit and continue editing this item. It depends on the type of data
being saved.
My point is just that for you to end up back at edit you have to have
a redirect in there somewhere. So it is not a bug in Cake by any
standard... possibly a limitation of some auto-magic that tries to
figure out where you want to be redirected to.
/Martin
On Mar 11, 1:07 pm, Danny Lieberman <[email protected]> wrote:
> Doh.
>
> Not exactly a bug but not exactly intuitive behavior either.
>
> I think that the correct behavior in the MVC model is for a controller
> function X to map to view X - both in invocation and on return.
>
> I would not have assumed that the view needs to explicitly specify
> return of control to the controller function that invoked the view in
> the first place.
>
> That behavior is a bit inconsistent I think.
>
> But - now I know
>
> Danny
>
> On Mar 11, 1:40 pm, majna <[email protected]> wrote:
>
>
>
> > yes, set controller and action params in form helper.
>
> > On Mar 11, 12:05 pm, Danny Lieberman <[email protected]> wrote:
>
> > > I have a controller with the usual CRUD functions and I added an
> > > additional function called fu (followup)
>
> > > The fu function has it's own fu.ctp view and after the user enters
> > > data in the form, it saves the data to the database using a save
> > > method
>
> > > The only problem is that cake always returns control after the form
> > > submit to the edit function, not the fu function. This is bolloxing
> > > up the application to say the least.
>
> > > I guess that this is some kind of automagic stuff but I have not been
> > > able to figure out how to ensure that control after save will not be
> > > automagically passed to an edit function
>
> > > Be happy to get an explanation how to fix this issue
>
> > > Danny
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---