Welcome Guest, Not a member yet? Register   Sign In
Exception in validation
#1

[eluser]Zimooon[/eluser]
Hi guys ,

In my CRUD i want to implement an exception:
If $active is set to 0 (inactive) the validation don't throw errors and let the form submit.
if $active is set to 1 (or whatever) the validation throws errors and behaves normal.

Code:
//rules
$this->form_validation->set_rules('title', 'Titel', 'required');
$this->form_validation->set_rules('content', 'Inhalt', 'required');
$this->form_validation->set_rules('date', 'Datum', 'required');
                  
    
        
  
      
if (($this->form_validation->run() == TRUE) || ($this->input->post('submit') && $active == '0'))  {        

          
   $title =$this->security->xss_clean($this->input->post('title','required|xss_clean'));
   $content=$this->security->xss_clean($this->input->post('content','required|xss_clean'));
   $date = strtotime($this->input->post('date','required|xss_clean'));
   $active = $this->input->post('active');
          
                
            
            // Add the post
            $this->posts_model->addPost($title,$content,$date,$image,$bigimage,$foldername,$active);
            $this->preview_model->deletePreview();                                    
            redirect('crud','refresh');

The problem here is: the errors get thrown either active checkbox is checked(1) or not (0).
Another problem will be ( i thin k so ) in update when $active is already 1 or 0 and the form gets immediatly submitted?

Hope you can help me.

Best regards.
Simon




Theme © iAndrew 2016 - Forum software by © MyBB