phpcodeignitergrocery-crud

How to change the default redirect after click on save button when you add data?


Everyone know, when add data by using grocery-crud, at end of the page there is a button named save to save the data in database.

This save button when clicked, save the data, then redirect to the data list page.

Now I'm use $crud->unset_list() method to unset the data list page.

Thus, when clicked on save button redirect to blank page, and that was the data list page.

My question:
How to redirect to a specific page as I want after clicked on save button, instead of redirect to data list page as it was

enter image description here
(source: grocerycrud.com)

enter image description here


Solution

  • These people seem to be having success using a JavaScript workaround:

    http://www.grocerycrud.com/forums/topic/324-workaround-redirect-to-the-list-after-insertupdate-without-changing-the-core-functionality-of-gc/

    Update:

    adding code for answer preservation...

    For Insert:

    $crud->set_lang_string('insert_success_message',
             '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 = "'.site_url(strtolower(__CLASS__).'/'.strtolower(__FUNCTION__)).'";
             </script>
             <div style="display:none">
             '
       );
    

    For Update:

    $crud->set_lang_string('update_success_message',
         '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 = "'.site_url(strtolower(__CLASS__).'/'.strtolower(__FUNCTION__)).'";
         </script>
         <div style="display:none">
    );