在没有实际表单提交的情况下使用CodeIgniter内置表单验证器类

时间:2022-10-06 16:42:40

Is it possible to validate a set of data (an array) with the form validation class in CodeIdniter? i.e. when there his no form submitted.

是否可以使用CodeIdniter中的表单验证类验证一组数据(数组)?即当他的表格没有提交时。

If it's not possible, what other way could I validate this data using the set of validation rules written in form_validation config file?

如果不可能,我可以使用form_validation配置文件中编写的验证规则集来验证这些数据吗?

Thanks in advance!

提前致谢!

2 个解决方案

#1


2  

I think you can validate any data using form validation, I have never tried, but it should work if you assign to $_POST array values manually (without submitting form) and then try to validate it.

我认为您可以使用表单验证来验证任何数据,我从未尝试过,但如果您手动分配$ _POST数组值(不提交表单)然后尝试验证它,它应该可以工作。

#2


1  

From the manual, under the section rule reference,

从手册中,在章节规则参考下,

Note: These rules can also be called as discrete functions. For example:

注意:这些规则也可以称为离散函数。例如:

$this->form_validation->required($string);

#1


2  

I think you can validate any data using form validation, I have never tried, but it should work if you assign to $_POST array values manually (without submitting form) and then try to validate it.

我认为您可以使用表单验证来验证任何数据,我从未尝试过,但如果您手动分配$ _POST数组值(不提交表单)然后尝试验证它,它应该可以工作。

#2


1  

From the manual, under the section rule reference,

从手册中,在章节规则参考下,

Note: These rules can also be called as discrete functions. For example:

注意:这些规则也可以称为离散函数。例如:

$this->form_validation->required($string);