Form Validation is_unique issue |
Hi,
To make a long story short. This is the body of the function : PHP Code: public function is_unique($str, $field) and it doesn't work in my case. Does not matter what is the real situation : PHP Code: return isset($this->CI->db)... throws an error. If instead of isset() I use is_object() - works fine. What is a reason of such a behavior ?
Since CI already has a built-in is_unique validation rule, I'm wondering where you're defining your function?
This is what I am talking about, this function (method), is used by CI3's "is_unique" validation rule and this function is an integrated part of CI3'S form validation library (line 1131).
Are you using Modular Extensions (HMVC) ?
Because i have the same issue, and it comes from the '$this->form_validation->CI =& $this;' that we have to add in order to have form_validation working with HMVC. But the problem with that is that line : $this->CI->db I'm trying to correct this right now. I'll tell you when it's working.
Finally i simply removed the MY_Form_validation file + $this->form_validation->CI =& $this; inside my class, and the form_validation seems to works well for the moment (+ the is_unique rule working perfectly).
10-06-2015, 10:09 PM
(This post was last modified: 10-07-2015, 06:24 AM by jinbatsu. Edit Reason: best way )
I have the same problem too here, using HMVC.
So if we remove using requiring by HMVC setup: MY_Form_validation file + $this->form_validation->CI =& $this. We cannot use custom validation callback, isn't it? In my case, thats break the flexibility. Best way is using callback, thats more flexible. |
Welcome Guest, Not a member yet? Register Sign In |