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

#1
Hello,

I write this bellow, my validation rules arre working, but the callback function not.
I'm new in codeigniter and maybe a little stupid, please help.

Code:
public function add_annonce_do()
    {
        $this->form_validation->set_rules('modele', 'Modèle', 'required');
        $this->form_validation->set_rules('annee', 'Année', 'required|callback_annee_check');
        $this->form_validation->set_rules('km', 'km', 'required');
        $this->form_validation->set_rules('prix', 'Prix', 'required');
        $this->form_validation->set_rules('description', 'Description', 'required');
        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('admin_header');
            $data['marque']=$this->marque->get_all_marque();
            $data['carburant']=$this->carburant->get_all_carburant();
            $this->load->view('annonce_add_display',$data);
            $this->load->view('admin_footer');
        }
        else
        {
            //traitement du formulaire
            $this->load->view('formsuccess');
        }
       
       

    }
    //callback validation
    public function annee_check($annee)
        {
                $current_year=date('Y');
                if (($annee <= 1870) || ($annee >= $current_year))
                {
                        $this->form_validation->set_message('annee_check', 'L’année n’est pas valide');
                        return FALSE;
                }
                else
                {
                        return TRUE;
                }
        }
Reply

#2
Look at the two words annee and Annee one of the e's has an accent above it.

Which makes the two words different.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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