【发布时间】:2015-08-10 08:05:46
【问题描述】:
我将尝试上传 Excel 文件并验证其内容。
所以我尝试了如下代码。
if ($this->upload->do_upload("filename"))
{
...
// I Think it is idiot code . . but . . anyway . . :_(
$_POST = array(
"name" => $cell[0],
"phone" => $cell[1],
"birth" => $cell[2],
...
);
$config = array(
array("field"=>"name", "label"=>"Name", "rule"=> "required"),
...
);
$this->form_validation->set_rules($config);
$this->form_validation->set_error_delimiters('', '');
if ($this->form_validation->run() === false)
{
throw new Exception($this->form_validation->error_string());
}
...
}
如何使用 form_validation 验证自定义数据?
【问题讨论】:
-
您使用
callback定义您的自定义规则。 -
查看页面 roytuts.com/custom-validation-example-in-codeigniter/
标签: php codeigniter validation