Codegniter의 설명서에서 복사하려고했지만 폼 유효성 검사 콜백이 작동하지 않습니다.Codeigniter - 양식 확인 콜백이 작동하지 않습니다.
도우미 양식, URL 및 라이브러리 form_validation을 추가했습니다. 그것은 노력하고 항상
컨트롤러
public function addtest()
{
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'callback_username_check');
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
if ($this->form_validation->run() == TRUE)
{
die('true');
}
else
{
die('false');
}
}
$this->template
->build('myform',array());
}
public function username_check($str)
{
if ($str == 'test')
{
return TRUE;
}
else
{
return FALSE;
}
}
보기
<form method="post" action="" class="form-horizontal form-label-left">
<div class="col-xs-12 col-md-9">
<div class="x_panel">
<div class="form-group col-xs-12">
<div class="col-xs-3">
<label class="control-label">Folder name</label>
</div>
<div class="col-xs-9">
<input type="text" name="username" value="" class="form-control " id="" placeholder="">
</div>
</div>
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
Codeigniter CallBack Functon에 대해 더 ($ 항상 througu 제공 this); ' – Gaurav
$ this를 추가했지만 다시 false를 반환합니다. –
요청 방법 확인을 제거하여 시도 할 수 있습니까? –