Forms in embedded views

#1
[eluser]garycocs[/eluser]
Hi Lads,

I don't think I explained myself well in the last post.

So I have a large page with 5 different forms in it.


Code:
function pub()
    {
        $countyname = $this->uri->segment(3);
        $townname = $this->uri->segment(4);        
        $pubname = $this->uri->segment(5);    
                
        if($countyname=="0") redirect('/');    
        
        $townname = addslashes(str_replace("-", " ", $townname));            
        $pubname = addslashes(str_replace("-", " ", $pubname));            
        $data['pid']     = $this->pub_model->get_pid($countyname,$townname,$pubname);
        $cid=$data['pid']['cid'];
        $tid=$data['pid']['tid'];
        $pid=$data['pid']['pid'];
        
        if ($cid==0) redirect('home/');    
                        
        $countyname = ucwords(strtolower(stripslashes($countyname)));
        $townname = ucwords(strtolower(stripslashes($townname)));
        $pubname = ucwords(strtolower(stripslashes($pubname)));        
                
        $fields['name'] = 'Name';
        $fields['email'] = 'Email';
        $fields['desc'] = 'Review';
        $fields['rate1'] = 'Talent';        
        $fields['rate2'] = 'Atmosphere';        
        $fields['rate3'] = 'Hospitality';        
        $fields['rate4'] = 'Pint Quality';                    
        
        $this->validation->set_fields($fields);
        
        $data['mytitle']    = "$pubname, $townname, $countyname";
        $data['myrobots']   = '<meta name="robots" content="noindex,nofollow" />';
        
        $data['base']       = $this->config->item('base_url');
        $data['css']        = $this->config->item('css');    
        $data['formvar']    = $this->uri->segment(6);    
        $data['pubinfo']     = $this->pub_model->get_pub_info($pid);
        $data['pubposition']     = $this->pub_model->get_pub_position($pid);
        $data['pubratings']     = $this->pub_model->get_pub_ratings($pid);    
        $data['pubpics']     = $this->pub_model->get_pub_pics($pid);        
        
        $data['pubaverage']     = $this->pub_model->get_pub_average($pid);
                            
        $this->load->view('pub_view', $data);
    }

What I would like to happen would be that when the user submits the form, they will be directed back to the same page but the form will have changed either to display the error or a thank you for submitting message where the form was.

I could repeat the above code for the 5 different methods called by the 5 different forms but this seems to be a lot of work. If I did a redirect it would save a lot of code duplication but I think I would lose the errors and the form repopulation?

Are there any other solutions?? I am also scratching the surface with prototype ajax etc.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.