使用 Get 参数时如何验证 Codeigniter 中的表单字段? [英] How do I validate a form field in Codeigniter when using Get parameters?

查看:28
本文介绍了使用 Get 参数时如何验证 Codeigniter 中的表单字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个完美运行的表单,直到我将表单切换到 method="get".现在我无法让 form_validation->run() 评估为 TRUE.

I have a form that worked perfectly until I switched the form to method="get". Now I can't get form_validation->run() to evaluate to TRUE.

我是这样打开表单的:

echo form_open( '', array( 'method' => 'get' ) );

这是唯一需要验证的部分:

This is the only piece that needs to validate:

$this->form_validation->set_rules( 'states', 'states', 'required' );

这是我检查表单是否经过验证的方式:

This is how I check to see if the form is validated:

if( $this->form_validation->run() == FALSE )

我还需要做些什么才能使用 Get 参数吗?我在配置中打开了参数( $config['allow_get_array'] = TRUE; ).如果我跳过验证,表单就可以正常工作,所以我知道 CI 系统正在读取 url.

Is there something else I need to do to use Get parameters? I have get parameters turned on in the config ( $config['allow_get_array'] = TRUE; ). The form works ok if I skip the validation, so I know the CI system is reading the url fine.

推荐答案

Codeigniter 论坛上的这篇帖子建议 表单验证不适用于获取参数,而这正是 Codeigniter 的方式.

This post on the Codeigniter Forum suggests that form validation does not work with Get Parameters and that is just the way Codeigniter is.

这篇关于使用 Get 参数时如何验证 Codeigniter 中的表单字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆