Codeigniter中的动态最大长度值

时间:2017-10-05 03:39:30

标签: codeigniter validation dynamic

我可以动态设置max_length验证吗?例如max_length['.$this->store->select($id)->stock.']< - 它无效

1 个答案:

答案 0 :(得分:0)

请确保$this->store->select($id)->stock返回有效数字:

$this->form_validation
      ->set_rules(
                   'your_field', 
                   'Label',  
                   'max_length['.$this->store->select($id)->stock.']'

                   // You can also trim it before checking length like below 
                  //'trim|max_length['.$this->store->select($id)->stock.']'
         );
相关问题