Welcome Guest, Not a member yet? Register   Sign In
Best pratice form Form with validation errors
#1

Hello
first sorry for my english
i'm upgrading a site from ci 2.1.6 to ci 3.1.5
the previous dev made 2 functions in a controller for form handeling
1 for loading the login view and 1 for the login process
if a form_validation with errors occured we were redirected by redirect() from the login_process function to the first login_view
in CI2 form validation errors where available after redirect, now IN CI3 it doesn't work anymore with this kind of setup
was this a bad practice?

how do we have to recode this stuff? only one controller as on the doc?

i tried this kind of code:
<?php

class Form extends CI_Controller {

       public function index()
       {
               $this->load->helper(array('form', 'url'));

               $this->load->library('form_validation');

               if ($this->form_validation->run() == FALSE)
               {
                       $this->load->view('myform');
               }
               else
               {
                       $this->load->view('formsuccess');
               }
       }
}

my problem is that the first view (index in the above sample code) is after a  post form, so when we are redirected to the the page we have a form validation error showwing

how can i fix that?
Reply


Messages In This Thread
Best pratice form Form with validation errors - by michaelv - 07-13-2017, 08:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB