⚠ 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

Preview Data Before Add Function Working...



likhon3k
  • profile picture
  • Member

Posted 06 May 2014 - 15:03 PM

Dear Coders,

I have a simple query. I want to preview a form data before add or inserting into database. do u tell me the easiest way to do?

 

Suppose: I have few fields in table. I want to insert data on it. I will click on Add Data link then a form will show.

 

I insert data into that form then when I click on Add Button then it will show the data like preview page. then If I agree then it will insert or disagree then it will back to form page.

 

any idea please?

 

 


Amit Shah
  • profile picture
  • Member

Posted 07 May 2014 - 05:43 AM

Well it is possible but then you need to create custom coding in this case. What you need to do here is - make a callback_insert where you pull out the data submitted - set it into a session and return true.

 

add the following code into your controller

$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">
         '

set it to whatever page you want. This will allow you to redirect to specific page post sucessful insert. On other page - retrieve data from session and display with confirm button and so on and on click of confirm button, write the code to fetch data from session and store it into the database. - DONE. But with this, you defying the use of GC as for adding the data (Your call)


likhon3k
  • profile picture
  • Member

Posted 26 June 2015 - 17:54 PM

Dear Amit,

After a long time... I tried with your given instruction but failed.

 

can you give me an example how can I do this?

 

I wanted to add data with preview option. If I add something then it will show preview that data first. If I confired to add then the data will be added.

 

Please give an example for a given example of GC tables.

 

Thanks.

 

Well it is possible but then you need to create custom coding in this case. What you need to do here is - make a callback_insert where you pull out the data submitted - set it into a session and return true.

 

add the following code into your controller

$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">
         '

set it to whatever page you want. This will allow you to redirect to specific page post sucessful insert. On other page - retrieve data from session and display with confirm button and so on and on click of confirm button, write the code to fetch data from session and store it into the database. - DONE. But with this, you defying the use of GC as for adding the data (Your call)