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

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

问题描述

我有一个表单工作完美,直到我将表单切换到 method =get。现在我不能得到 form_validation-> run()来计算为TRUE。



打开窗体:

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

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

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

这是我如何检查表单是否通过验证:

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

使用Get参数需要做些什么?我得到参数打开在配置( $ config ['allow_get_array'] = TRUE; )。

解决方案

这篇文章是关于Codeigniter论坛建议表单验证无法使用获取参数,这只是Codeigniter的方式。 / p>

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.

This is how I open the form:

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 )

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.

解决方案

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天全站免登陆