0

I am using codeigniter. Below is the form validation set rule

unique[bf_product.product_order,bf_product.id]
  • bf_product = table name

  • product_order = column name

    I want to add another column i.e: product_category names to unique rule in form validation.

So that the product can be fetch on the basis of product_order and product_category, and the user can't input same order no. for a particular category.

Example:

  1. Product category 1 - product - sort order = 1
  2. Product category 1 - product - sort order = 1 (Not possible,already exist)
  3. Product category 2 - product - sort order = 1 (Possible)
Community
  • 1
  • 1
Moeed Farooqui
  • 3,604
  • 1
  • 18
  • 23

1 Answers1

0

Not sure if it can be done by unique, As per documentation it checks for a single column only. Would recomment you to go for callbacks:

$this->form_validation->set_rules('ele', 'alias', 'callback_check_product');

function check_product( $ele ){
    #check here with the $ele and return TRUE / FALSE
}
Nil'z
  • 7,487
  • 1
  • 18
  • 28