【发布时间】:2017-11-12 12:37:25
【问题描述】:
我正在使用 CodeIngiter 创建一个安静的应用程序。
我想知道是否可以将 FormValidation 类与非 $_POST 数据一起使用。
我在想:如果客户端以这种方式发送 GET 请求:
https://myrestapp.com/controller?firstValue=val&secondValue=val2
如何使用这个验证 firstValue 和 secondValue:
//example
$this->form_validation->set_rules('firstValue', , 'required');
$this->form_validation->set_rules(secondValue, , 'required|integer');
以及,如何将<?php echo validation_errors(); ?> 转换为array('firstValue' => "The field secondValue must be integer") 之类的关联数组
【问题讨论】:
-
是的,你可以 - 见codeigniter.com/userguide3/libraries/…
-
Ops,我从来没有读过那一段。对于关联数组?
-
没关系,直到我去寻找之前我都没有,因为这是一个有趣的问题:)
-
那么,有什么解决方案可以为 validation_errors() 创建关联数组吗?
标签: php codeigniter