⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Redirect after insert/update



Nicholas
  • profile picture
  • Member

Posted 12 January 2012 - 21:15 PM

Can you think of a good way to redirect after an insert/update event? Preferrably an onSuccess() sort of thing that would still have access to post parameters.

My initial efforts in callback_after_insert were not successful, so I'm poking around in the library, but thought you might have an idea.

Thanks for any thoughts, the library usage continues to be a real success for me.

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 12 January 2012 - 21:28 PM

[quote name='Nicholas' timestamp='1326402912' post='270']
Can you think of a good way to redirect after an insert/update event? Preferrably an onSuccess() sort of thing that would still have access to post parameters.

My initial efforts in callback_after_insert were not successful, so I'm poking around in the library, but thought you might have an idea.

Thanks for any thoughts, the library usage continues to be a real success for me.
[/quote]
You can change the javascript to do all the sucess with a redirection to the list page .

Here is the post of how you can do that : http://www.grocerycr...indpost__p__246 , this is the datatables themes so the similar thing you will change in flexigrid theme too.

The redirection doesn't work if you try it with the header("Location: ...."); or with the redirect of CI. This is normal as all the requests are ajax.

Nicholas
  • profile picture
  • Member

Posted 12 January 2012 - 21:36 PM

Great, I had already found my way into the js. Seems like I can put a little hack in as well, on the php side

$crud->redirect_url

and if it exists add a redirect param to the ajax response, then finally in js

if(data.success)
{
if (data.redirect) {
window.location.href = data.redirect;
}


That should allow me to pass params in there nicely, and have different (or no) redirect for my other screens.

Thanks for the super quick response btw.

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 12 January 2012 - 21:48 PM

[quote name='Nicholas' timestamp='1326404169' post='272']
Great, I had already found my way into the js. Seems like I can put a little hack in as well, on the php side

$crud->redirect_url

and if it exists add a redirect param to the ajax response, then finally in js

if(data.success)
{
if (data.redirect) {
window.location.href = data.redirect;
}


That should allow me to pass params in there nicely, and have different (or no) redirect for my other screens.

Thanks for the super quick response btw.
[/quote]

I think this is even better for you ;)

drfunk
  • profile picture
  • Member

Posted 24 August 2013 - 20:26 PM

First of all, once again many thanks to the creator of "grocery crud"

 

for some reasons i would prefer pure "php"  solution

to automatically redirect after inserting with "add form" to "edit form"

 

callback_after_insert unfortunately does not work for this

 

can someone help me!