• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
validation problem

#1
[eluser]dimis[/eluser]
I use the validation class of the CI 1.7 but can not write the validation errors.
Code:
$this->load->library('form_validation');
        $name=array();
        $lancode=$this->lans->returnonlycode();
        foreach ($lancode as $lan=>$value)
        {
            $el=$value['lan_code'];
            $this->form_validation->set_rules("name_$el", "name_$el", 'required');
            $this->form_validation->set_rules("descr_$el","descr_$el", 'required');

        }
      
        if ($this->validation->run() == FALSE )
        {
            //the validation_errors() is empty
            $this->db_session->set_flashdata('prderror',  validation_errors());
            $this->db_session->set_flashdata('active', $this->input->post('active'));
            foreach ($lancode as $lan)
            {
                $this->db_session->set_flashdata("descr_".$lan['lan_code'], $this->input->post("descr_".$lan['lan_code']));
                $this->db_session->set_flashdata("name_".$lan['lan_code'], $this->input->post("name_".$lan['lan_code']));
            }
            redirect('manager/cats/newcat/','refresh');
        }
What is wrong.

#2
[eluser]dimis[/eluser]
This were the error
Code:
if ($this->validation->run() == FALSE )

#3
[eluser]izzyGuy72[/eluser]
Change:

if ($this->validation->run == false)

to

if ($this->form_validation->run == false)

It should work since you are calling the form_validation library. Hope this helps.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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