我目前正在使用表单验证类(在 Codeigniter 上)并设置规则。
它使用两个参数(codeigniter.com/user_guide/libraries/form_validation.html)像这样工作:
$this->form_validation->set_rules('username', 'Username', 'callback_test[abc]');
但是第三个参数呢?还有第四个……?可能吗?
我目前正在使用表单验证类(在 Codeigniter 上)并设置规则。
它使用两个参数(codeigniter.com/user_guide/libraries/form_validation.html)像这样工作:
$this->form_validation->set_rules('username', 'Username', 'callback_test[abc]');
但是第三个参数呢?还有第四个……?可能吗?
它不是官方的,但有效
用 ',' 分割参数
$this->form_validation->set_rules('article_big_image','Gambar Besar','callback_check_picture[article_big_image,edit]');
function check_picture($image,$param){
    $param = preg_split('/,/', $param);
    $field = $param[0];
    $action = $param[1];
    echo $field.$action;
}
    并非没有扩展系统表单验证类。有关如何实现这一点的信息,请查看这篇文章。
或者,您可以使用以下方法访问回调函数中的 post 变量:
$this->input->post('field_name');
这可能会也可能不会帮助你。
您可以将 Array 用于更多字段的更多参数,如下所示:
 $error = array(
                array(
                'field' => 'check', // the field name will come here
                'label' => 'Check',
                'rules' => 'required|here you can put the callback Function'
                )
          );
    
    $this->form_validation->set_rules('article_big_image','Gambar','callback_check_picture[article_big_image,edit]');
    function check_picture($image,$param){
        $param = explode(',', $param);
        $field = isset($param[0])?$param[0]:'';
        $action = isset($param[1])?$param[1]:'';
       echo $field.$action;
   }
    你可以传递给规则
|callback_handle_is_unique_value_combinations[val1,val2]
比,
 public function callback_handle_is_unique_value_combinations($str, $field)
    {
        $fields = explode(',', $field);
        $val1 = $fields[0];
        $val2 = $fields[1];
然后你做了你的cponarisons