I am using CakePHP and I have something like:
PRODUCT -------> PRODUCT_CATEGORY <---------- CATEGORY
therefore, one product may have categories of "n" and vice versa. The problem is that I would like to check products to have at least one category. Since I use a form helper, and CakePHP y validation functions came to this:
class Product extends AppModel {
var $name = 'Product';
var $validate = array(
'category_id' => array(
'rule' => array('multiple', array('min' => 1)),
'message' => 'You have to choose at least one category'
)
);
}
But it doesn’t work, any ideas?
source
share