2010-07-05 3 views
2

안녕이 내 양식 유효성 검사에 문제가 있어요 기본적으로 문제는 내가 유효성 검사가 실패 할 경우, 내 코드를 참조하십시오로드 반복보기, 기본적으로CodeIgniter의 form_validation 도움

else { 
      //the user is a new customer so we need to show them 
      //the card details form 
      $this->addViewData('returningCustomer', false); 
      $this->load->library('form_validation'); 
      if($this->input->post('carddetails') == 'Submit') { 
       $this->form_validation->set_rules('inpcardtype', 'Card type', 'cardTypeCheck'); //custom callback 
       $this->form_validation->set_rules('inpcardnumber', 'Card number', 'required|trim|exact_length[16]'); 
       $this->form_validation->set_rules('startmonth', 'Start month', 'trim|required'); 
       $this->form_validation->set_rules('startyear', 'Start year', 'trim|required'); 
       $this->form_validation->set_rules('endmonth', 'End month', 'trim|required'); 
       $this->form_validation->set_rules('endyear', 'End year', 'trim|required'); 
       $this->form_validation->set_rules('inpissuenumber', 'Issue number', 'trim|integer'); 
       $this->form_validation->set_rules('inpccv', 'CCV Code', 'required|trim|exact_lenght[3]'); 
       if($this->form_validation->run() == FALSE) { 
        $this->renderTemplate('cv/search/pf_shortlist.php', $this->viewData); 
       } else { 
        // validation is passed we need to safe the user details 
        // it is probable that we will need to hash the users card details 
        //@TODO: HASH USER CARD DETAILS LEAVE ONLY THE FINAL DIGITS 
        $this->load->model('checkout_model'); 
       } 
      } 
      $this->renderTemplate('cv/search/pf_shortlist.php', $this->viewData); 

경우를 얻고 있다는 것입니다 condtion이 뷰를 폼과 함께로드 된 스크립트보다 더 많이 실패하면 폼이 제출되고 유효성 검사가 실패하면 사용자는 폼으로 다시 전달되지만 오류가 표시되지만 원래 뷰도 표시됩니다. 이 일을 그만 둘 수 있습니까?

답변

1

당신은 다른 문 다음으로 return;을해야

다른보기로드 프로그래머

$this->renderTemplate('cv/search/pf_shortlist.php', $this->viewData);

. #

 //the user is a new customer so we need to show them 
     //the card details form 
     $this->addViewData('returningCustomer', false); 
     $this->load->library('form_validation'); 
     if($this->input->post('carddetails') == 'Submit') { 
      $this->form_validation->set_rules('inpcardtype', 'Card type', 'cardTypeCheck'); //custom callback 
      $this->form_validation->set_rules('inpcardnumber', 'Card number', 'required|trim|exact_length[16]'); 
      $this->form_validation->set_rules('startmonth', 'Start month', 'trim|required'); 
      $this->form_validation->set_rules('startyear', 'Start year', 'trim|required'); 
      $this->form_validation->set_rules('endmonth', 'End month', 'trim|required'); 
      $this->form_validation->set_rules('endyear', 'End year', 'trim|required'); 
      $this->form_validation->set_rules('inpissuenumber', 'Issue number', 'trim|integer'); 
      $this->form_validation->set_rules('inpccv', 'CCV Code', 'required|trim|exact_lenght[3]'); 
      if($this->form_validation->run() == FALSE) { 
       $this->renderTemplate('cv/search/pf_shortlist.php', $this->viewData); 
       return;// HERE 
      } else { 
       // validation is passed we need to safe the user details 
       // it is probable that we will need to hash the users card details 
       //@TODO: HASH USER CARD DETAILS LEAVE ONLY THE FINAL DIGITS 
       $this->load->model('checkout_model'); 
      } 
     } 
     $this->renderTemplate('cv/search/pf_shortlist.php', $this->viewData); 
     return;