Welcome Guest, Not a member yet? Register   Sign In
Form Validation is_unique issue
#1

(This post was last modified: 05-25-2015, 11:47 AM by tj_gumis.)

Hi,

To make a long story short. This is the body of the function :
PHP Code:
   public function is_unique($str$field)
 
   {
 
       sscanf($field'%[^.].%[^.]'$table$field);

 
       return isset($this->CI->db)
 
           ? ($this->CI->db->limit(1)->get_where($table, array($field => $str))->num_rows() === 0)
 
           FALSE;
 
   

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 ?
Reply
#2

Since CI already has a built-in is_unique validation rule, I'm wondering where you're defining your function?
Reply
#3

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).
Reply
#4

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.
Reply
#5

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).
Reply
#6

(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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB