【发布时间】:2012-09-29 12:51:20
【问题描述】:
可能重复:
Codeigniter 2 forms on one page, validation_errors problem
我的页面中有 2 个表单。我需要一次验证它们 1,但我认为存在冲突。这里看看:
当我提交任何一个表单时,它们都显示相同的错误消息
我使用validation_errors() 来显示消息。如何一次验证表单 1?
这里是代码
public function update_user_info(){
$this->form_validation->set_rules("firstname","First Name","required");
$this->form_validation->set_rules("lastname","Last Name","required");
$this->form_validation->set_rules("middlename","Middle Name","required");
if($this->form_validation->run()===false){
//wrong
}
else { //correct }
}
【问题讨论】:
-
http://stackoverflow.com/questions/5802729/codeigniter-2-forms-on-one-page-validation-errors-problem -
公共函数 update_user_info(){ $this->form_validation->set_rules("firstname","First Name","required"); $this->form_validation->set_rules("lastname","Last Name","required"); $this->form_validation->set_rules("middlename","Middle Name","required"); if($this->form_validation->run()===false){ //错误 }else{ //正确 } }
标签: php codeigniter