Jump to content


callback before insert not working

callback insert 1.4.1

  • Please log in to reply
No replies to this topic

#1 Mamdouh AlRamadan

Mamdouh AlRamadan

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 17 October 2013 - 05:22 AM

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.







Also tagged with one or more of these keywords: callback, insert, 1.4.1

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users