php - Primary key field is not getting validated for uniqueness in cakephp -


i working on cakephp framework,where mysql end.i developing form enter product details,where product_id added manually.i have written validation rules product_id field.it works other validation rules i.e. not empty, numeric.but not working unique validation rule.here validation code in model:

var $validate= array(product_id=>                                   'numeric'=> array('rule'=>'numeric',                   'on'=>'create',                   'message'=>'please enter numbers'),                                   'isunique' => array('rule' => 'isunique',                         message' => 'this product_id exist'),                   'notempty'=> array('rule' => 'notempty',                         message' => 'please enter product id')),              'product_name' => array('notempty'=> array(                                     'rule' => 'notempty',                                     'message' => 'please enter product name'))); 

i couldn't able point out error location.

shouldn't be:

var $validate= array('product_id'=> array('rule'=>'numeric',                     'on'=>'create',                      //etc 

else attempting validate field called numeric?

also, whilst don't know how app functions, using product_id sounds should relate record, in products table - automatically dealt with cake i.e. in select.

if entering unique code (such internal reference number), consider renaming field less-cake-like prevent issues may arise, or confusion cake developer.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -