查看輸入值返回
<div class="box-body">
<div class="form-group">
<label for="FNAME" class="col-sm-2 control-label col-sm-offset-2"> <span>*</span>First Name:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="FNAME" name="FNAME">
</div>
</div>
<div class="form-group has-error col-sm-offset-7">
<label class="control-label" for="error"><?php echo form_error("FNAME"); ?></label>
</div>
</div>
控制器
public function create_id() {
$this->form_validation->set_rules('FNAME', 'First Name' ,'trim|required|max_length[30]');
$this->form_validation->set_rules('MNAME', 'Middle Name' ,'trim|max_length[30]');
$this->form_validation->set_rules('SURNAME', 'Last Name' ,'trim|required|max_length[30]');
if($this->form_validation->run($this) == FALSE) {
$this->add_view();
} else {
if($query = $this->Employees_Model->insert()) {
$this->autoid();
redirect('Employees/index');
} else {
$this->add_view();
}
}
}
我要的是if($this->form_validation->run($this) == FALSE){
你看它會回重定向到視圖。我想要的全部是當它重新導向時,我輸入的數據將保持不變。這樣當驗證失敗時我不會再輸入它。
這可以幫助你https://ellislab.com/笨/用戶指南/庫/ form_validation .html#repopulatingform – urfusion