Jump to content


validate fields according option.

required field

  • Please log in to reply
2 replies to this topic

#1 Maicol Ortiz Tello

Maicol Ortiz Tello

    Newbie

  • Members
  • Pip
  • 4 posts
  • LocationLa Serena , Chile.

Posted 16 November 2014 - 05:11 AM

Hi all, I have a problem I need help.
tenho a form to add an article and a select box at the beginning if it is to indicate whether the article or just an image. good is that based on the choice of the select box depends hide and show some input that's ok, but I need some input validation and other all depends on the option chosen.
img1.PNG
 
img2.PNG

 



#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 16 November 2014 - 10:33 AM

hi there

i will share you this piece of code thats there for validating confirm password if the password is set

 

            $required_if = $this->input->post('new_password') ? '|required' : '' ;
            $validation_check = $this->input->post('new_password') ? '|required|matches[confirm_passwd]' : '' ;
            $crud->set_rules('confirm_passwd', 'New Password', 'trim'. $required_if);
            $crud->set_rules('new_password', 'New Password Again', 'trim'.$validation_check);

 

This might help you understand the same. u might jet go through the same :)



#3 Maicol Ortiz Tello

Maicol Ortiz Tello

    Newbie

  • Members
  • Pip
  • 4 posts
  • LocationLa Serena , Chile.

Posted 16 November 2014 - 03:14 PM

perfect! I had not thought I did not think they could capture fields with $ this-> input-> post ();

 

my solution ...
    $post=$this->input->post();
    if($post['is_article']==1){
        $crud->required_fields('title','text','is_article','image');
    }else{
       $crud->required_fields('title','is_article','image'); 
    }

Thanks Amit Shah, Greetings from Chile!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users