Welcome Guest, Not a member yet? Register   Sign In
CI 1.7 - Form Validation Config File rules are lost if there are additional uri segments
#1

[eluser]JayTee[/eluser]
This isn't really a 'bug' per se, but it cost me 1/2 hour of problem solving:

Scenario:
http://www.example.com/index.php/control...ion/param1

contains a form that posts to itself using the uri_string() function:
Code:
<form action="http://www.example.com/index.php/controller/function/param1">

but your application/config/form_validation.php file shows the rule like this:
Code:
$config = array(
  'controller/function' => array(
    array(
      'field' => 'login',
      'label' => 'Login Name',
      'rules' => 'required'
    ),
    array(
      'field' => 'password',
      'label' => 'Password',
      'rules' => 'required'
    )
  )
);

In this scenario, the validation class will not find the validation rule - because it's looking for a rule called 'controller/function/param1'!

I changed the form so that it posts to the controller's function directly rather than cheating and using the uri segments in lieu of hidden form fields.

I'm sure this is by design; it can also be a 'gotcha' if a user happens to be posting a form to a URL that contains additional uri segments.
#2

[eluser]sikkle[/eluser]
Hey JayTee,

i think what your want to confirm is the way user can use $this->form_validation->run('array_name_in_form_validation_config_file');

If you leave it empty he look automatically to guest with the url if not, he look for the index you put there.

I missed that one at first too.

good luck!
#3

[eluser]JayTee[/eluser]
I didn't test that particular way - I went with the hidden form field approach and that seems to work OK; I just have to keep in mind what's going on behind the scenes.




Theme © iAndrew 2016 - Forum software by © MyBB