【发布时间】:2012-05-03 15:24:27
【问题描述】:
我正在构建一个小型应用程序,它基本上会显示 3 种形式...第一个是可选的,第二个不是,第三个不是。我希望每个表单都是一个单独的 url(控制器)。在阅读 CodeIgniter form_validation 的文档时,该表单似乎只能提交给它自己进行验证。如果是这样的话,表格将继续显示在同一页面上......他基本上就是我所拥有的......并评论了我想做的事情......
class Index extends CI_Controller {
function __construct()
{
parent::__construct();
}
function index()
{
//load front page that contains first form...
$content['title'] = 'Home';
$content['view'] = 'pages/index';
$this->load->view('template/default',$content);
}
function step_two()
{
//recieve information from front page. validate form. If validation is
//successful continue to step_two(url) if it fails redirect
//to front page with error...
$this->form_validation->set_rules('serial', 'Serial Number', 'required');
if ($this->form_validation->run() == FALSE)
{
//return to front page...
}else{
//do necessary work and load step_two view
}
}
}
?>
这是我的想法。但我注意到的是,除非表单提交给它自己,否则你不能进行表单验证。有任何想法吗?我应该验证表单然后重定向到新的 url/函数吗?
谢谢大家...
【问题讨论】:
-
验证成功时重定向...
标签: php codeigniter validation