2012-02-08 3 views
2

내 양식이 항상 유효성 검사에 실패하는 이유를 누구나 찾아 낼 수 있습니까? 유효성 검사에서 오류가 출력되지 않고 POST 배열이 항상 비어 있습니다. 나에게 제안한다, 그것이 틀린 장소에 제출된다. 그러나 그것은 사실이 아니다. 여기 CodeIgniter form_validation을 사용한 빈 POST 결과

<form action="https://www.mydomain.com/account/withdraw" method="post" accept-charset="utf-8">  <fieldset class="six-col"> 
     <h3>What amount?</h3> 
     <span style="font-size:1.3em;position:relative;display:inline;">&pound;</span> 
     <input id="amount" type="text" placeholder="1.00" style="font-size:1.3em;width:115px;background-color: transparent;color:white;"/> 

    </fieldset> 
    <fieldset class="six-col"> 
     <h3>Charges</h3> 
     <span id="charges" style="font-size:1.3em;"></span> 
    </fieldset> 
    <fieldset class="six-col"> 
     <h3>You leave with</h3> 
     <span id="charges2" style="font-size:1.3em;"></span> 
    </fieldset> 
    <fieldset class="six-col end-col"> 
     <input type="submit" id="submit" class="btn" value="Withdraw" style="width:125px;position:absolute;bottom:0" /> 
    </fieldset> 
</form> 

당신은 입력에서 설정 한 이름이없는 어떤 도움

답변

5

에 대한

$this->load->library('form_validation'); 

    $this->form_validation->set_rules('amount', 'Amount', 'required|xss_clean|trim|numeric|max_length[5]'); 

    if ($this->form_validation->run() == FALSE) 
    {   
     $this->load->helper(array('form', 'url')); 
     $data['credit'] = $this->account_m->get_credit(); 
     $this->load->view('account/withdraw', $data); 
    } 
    else 
    { 
     // The withdraw code 
    } 
    $this->load->view('footer'); 

감사 컨트롤러입니다 .. 가 있어야한다 : <input name="amount" id="amount" type="text" placeholder="1.00" style="font-size:1.3em;width:115px;background-color: transparent;color:white;"/>

것이 확인 당신은 실제로 뭔가를 얻고 있습니다.

가능한 모든에서 테스트 할 경우 ..

지금처럼 form_validation 전에 포스트 VAR 에코 :

<?php echo $this->input->post('amount'); ?> 

그런 다음 다시 양식을 값을 받고 있지 않은 경우, POST 대신 post의를 사용해보십시오.

값을 얻는다면 그 규칙을 다시 얻으십시오. 하나의 가능성은 numeric 규칙입니다. 정수를 사용하십시오. is_natural을 시도하거나 $ 0.00을 사용하는 경우 decimal을 시도하십시오. 또한

, 개발에 사용 CodeIgniter의의 프로파일 클래스 .. http://codeigniter.com/user_guide/general/profiling.html

<?php $this->output->enable_profiler(TRUE); ?> 
+2

좋은 캐치, name''없는 것을 알하지 않았다. +1 – DaveRandom

+0

저는 항상 그 일을합니다. CIs 프로파일 러는 Google 크롬 개발자 툴킷을 통해 XHR 헤더를 모니터링하거나 모니터링 할 수있는 훌륭한 도구입니다. – gorelative

+0

빌어 먹을 유예 기간! 나는 당신이 그것을 추가했다는 것을 보았다. (누락 된 이름 부분) 나는 나의 대답을 게시하고 있었다. :) +1 어쨌든 –