⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

callback_before_update not work, please help me



Mahar Prasetio

Mahar Prasetio
  • profile picture
  • Member

Posted 29 November 2012 - 12:22 PM

Scenario : I want to Qty field that already inserted to the database and not going to change the Qty value. Before update it return a Total field.
Here code in controller

$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->where('HeaderId', $headerid);
$crud->set_table('trpurchasingdetail');
$crud->field_type('HeaderId', 'hidden' , $headerid)
->field_type('Total', 'invisible');
$crud->set_relation('productId', 'msproduct', 'productName');
$crud->set_subject('Price');
$crud->display_as('PriceCurrency', 'Price')
->display_as('productId', 'Product Name')
->display_as('DetailRemarks', 'Detail Product')
->display_as('UnitType', 'U/M');
$crud->fields('PriceCurrency','Qty');
$crud->unset_columns('HeaderId')
->unset_add()
->unset_delete()
->unset_print()
->unset_export();
$crud->callback_before_update(array($this->transaction, 'totalPrice'));
$output = $crud->render();
$output->hasil = $this->db->query("SELECT Number FROM trpurchasingheader
WHERE Id = '$headerid'")->row();
$output->type = "Order No";
$output->link = "index.php/purchasing/transaction";
$output->direct = "Purchasing List";
$this->load->view('listproduct', $output);


And this the function that will be called before update

	function totalPrice($post_array, $primary_key) {
$harga = $post_array['PriceCurrency'];
$qty = $post_array['Qty'];
$post_array['Total'] = $harga * $qty;
return $post_array;
}


I've try this function with callback_before_insert and it works perfectly, but when I use this function with callback_before_update it not return any value.

Sorry for my bad english :)

SOLVED Sorry :D