CodeIgniter Forums
problem with form_validation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: problem with form_validation (/showthread.php?tid=62914)



problem with form_validation - keulu - 09-07-2015

hi guys,

I had some troubles today with the form_validation lib, when i run the validation from a controller inside a folder

with an uri like that
Code:
/folder/controller/method
form_validation always return false in CI 3.0.1, everything work with the 3.0-dev or 3.0.0.

with an uri like that
Code:
/controller/method
, everything is ok too.

is that a bug ?


RE: problem with form_validation - mwhitney - 09-08-2015

Since most of my controllers are nested inside directories, I'm going to say no, but you probably need to show some code for anyone to be able to figure out what is happening in your case.


RE: problem with form_validation - keulu - 09-09-2015

here is my method from a controller named Groups.php on controllers/zabbix/Groups.php

PHP Code:
public function index()
{
 
$this->load->library('form_validation');
 if (
$this->session->has_userdata('group_search') || $this->form_validation->run('zabix_groups_search')) {
 
 if (
$this->form_validation->run('zabix_groups_search')){
 
$groups $this->group_model->GetGroupsWhere($where=array('name' => $this->input->post('group_search')));

 if (
count($groups) > && $this->input->post('group_search') != ""$this->session->set_userdata('group_search'$this->input->post('group_search'));

 }else{
 
$groups $this->group_model->GetGroupsWhere($where=array('name' => $this->session->has_userdata('group_search') ? $this->session->group_search ''));

 }
 }else{
 
$groups false;
 }
 
 
$this->data array_merge(compact('groups'), $this->data);
 
 
$this->load->view('zabbix/groups/index'$this->data);


as i said, $this->form_validation->run('zabix_groups_search') always return false, but $this->input->post('group_search') is ok


and this is my config for the validation



PHP Code:
'zabix_groups_search' => array(
            
    array(
 
     'field' => 'group_search',
 
     'label' => 'Recherche de groupe',
 
     'rules' => ''
 
   ),
        
 
 ), 



RE: problem with form_validation - Avenirer - 09-09-2015

I don't understand. That is the config for the validation? You mean that is what the file contains?


RE: problem with form_validation - keulu - 09-09-2015

no that's just a part of my array


RE: problem with form_validation - mwhitney - 09-09-2015

Are you using CI 3.0 or 3.0.1? There's a bug fix in 3.0.1 that allows empty rules, but the 3.0 version of the form validation library will always fail on an empty rule.


RE: problem with form_validation - keulu - 09-10-2015

that bug appear on CI 3.0.1 in my case.

everything work o CI 3.0.0 or CI 3.0-DEV


RE: problem with form_validation - keulu - 01-15-2016

sorry for disinter that topic, but i've found the problem.

if you submit a form and if you have a form_validation config file with your form entry in it,

Like that for example

PHP Code:
'zabix_groups_search' => array(

        array(
          
'field' => 'group_search',
          
'label' => 'Recherche de groupe',
          
'rules' => '',
        ),

        array(
          
'field' => 'search',
          
'label' => '',
          
'rules' => '',
        ),

      ), 

the form validation will fail, apparently because no one fields is required.

if i add the key "required" to my search (submit button) everythig works fine.

maybe an issue ?


RE: problem with form_validation - Avenirer - 01-15-2016

Well... I still don't understand why would you make a form validation rule without rules...


RE: problem with form_validation - keulu - 01-15-2016

yeah, my bad, that was a mistake.

But if I did that, maybe someone else will do the same one day Smile