Welcome Guest, Not a member yet? Register   Sign In
Redirect with input
#1

I think we need something similar like in Laravel: 
https://laravel.com/docs/5.3/responses#r...ssion-data
https://laravel.com/api/5.2/Illuminate/H...ponse.html

Why we need this? To show the form in one action method and in the other one handle the data processing...

For CodeIgniter 3 I use a similar but very simple solution to achieve the same results, see below...

I put the following code to the MY_Controller constructor:
PHP Code:
$_previous_data $this->session->flashdata('_previous_data');
if(
$_previous_data)
{
    
$_POST    $_previous_data['post'];
    
$_GET    $_previous_data['get'];


...and I created the following helper method for the redirect:
PHP Code:
if( ! function_exists('redirect_with_input'))
{
    function 
redirect_with_input($uri ''$method 'auto'$code NULL)
    {
        
$CI =& get_instance();

        
$data = array(
            
'post'    => $CI->input->post(),
            
'get'    => $CI->input->get()
        );

        
$CI->load->driver('session');
        
$CI->session->set_flashdata('_previous_data'$data);

        
redirect($uri$method$code);
    }


I am not saying we should use something similar, it's just here to show an implementation... Laravel's approach is much cleaner & have more options...
Reply


Messages In This Thread
Redirect with input - by orionstar - 01-03-2017, 01:53 PM
RE: Redirect with input - by kilishan - 01-03-2017, 03:23 PM
RE: Redirect with input - by orionstar - 01-04-2017, 05:15 AM
RE: Redirect with input - by kilishan - 01-06-2017, 07:38 PM
RE: Redirect with input - by Diederik - 01-07-2017, 01:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB