⚠ 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

Get the insert key before redirect



walter.wabe

walter.wabe
  • profile picture
  • Member

Posted 12 September 2012 - 17:28 PM

Hi

I want to know if there is a way to get the primary key of an inserted element, and use it to redirect to another controller and function using the key as parameter.

[color=#282828][font=helvetica, arial, sans-serif]I have an example from a previous post :[/font][/color]


[color=#000000]$crud[/color][color=#666600]->[/color][color=#000000]set_lang_string[/color][color=#666600]([/color][color=#008800]'insert_success_message'[/color][color=#666600],[/color]
[color=#000000] [/color][color=#008800]'Your data has been successfully stored into the database.<br/>Please wait while you are redirecting to the list page.
<script type="text/javascript">
window.location = "'[/color][color=#666600].[/color][color=#000000]site_url[/color][color=#666600]([/color][color=#000000]$controller[/color][color=#666600].[/color][color=#008800]'/'[/color][color=#666600].[/color][color=#000000]$function[/color][color=#666600].[/color][color=#008800]'/'[/color][color=#666600].[/color][color=#000000]$primary_key[/color][color=#666600]).[/color][color=#008800]'";
</script>
<div style="display:none">
'[/color]
[color=#000000] [/color][color=#666600]);[/color]


[color=#282828][font=helvetica, arial, sans-serif]Thanks for your help [/font][/color]

midnigther

midnigther
  • profile picture
  • Member

Posted 13 September 2012 - 01:24 AM

Your question seems a bit confused. However if you want redirect to another controller after the insert action you can use callback_after_insert () function.

If you want redirect to another controller with the last inserted element in the grid, try create a session to grab the last element.