This is my code:
public function special_management()
{
try{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('specialx');
$crud->set_subject('Special');
$crud->required_fields('something');
$crud->set_relation('variant_id', 'variant', 'item_number');
$crud->callback_before_insert(array($this,'check_special_validity'));
$output = $crud->render();
$this->_admin_output($output);
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
function check_special_validity($arr)
{
$this->load->model('specialx');
$value = $this->specialx->check_special_on_item($arr['item_number'],$arr['expiration_date']);
return $value;
}
what's driving me crazy is that when I test on separate controller I get
value = false
but GC ignores it and inserts into the database.
any help?
Update:
item_number is a result of set_relation so that's why it's not defined in $arr.
my updated question would be how to pass it with $arr in callback.
Update 2:
Solved by passing the relational element instead of item_number.
