⚠ 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_column not working for connected tables



Fasil iocod.com

Fasil iocod.com
  • profile picture
  • Member

Posted 28 May 2013 - 13:00 PM

I am trying to change column value using callback_column function.

$crud = new grocery_CRUD();
$crud -> set_table('booking');
//$crud->set_relation('room_id','rooms','name');
$crud->callback_column('room_id',array($this,'_visitor_details_popup'));
 

This code workings well(_visitor_details_popup function return value to room_id)

$crud = new grocery_CRUD();
$crud -> set_table('booking');
$crud->set_relation('room_id','rooms','name');
$crud->callback_column('room_id',array($this,'_visitor_details_popup')); 

This code NOT workings well(room_id not changing)

 

Is this a bug in grocery crud?? Any tricky way to solve it??


davidoster

davidoster
  • profile picture
  • Member

Posted 29 May 2013 - 04:54 AM

Hello and welcome to the forums.

Actually there is a small bug when you try to use set_relation and callback_column together.

You need to use the following function (just put it somewhere inside your controller), 

// fix for set_relation break on callback_column
	function unique_field_name($field_name) 
	{
		return 's'.substr(md5($field_name),0,8); //This s is because is better for a string to begin with a letter and not with a number
    }

and use it like this (sample code),

$this->grocery_crud->callback_column($this->unique_field_name('customers_id'),array($this,'_callback_attend_edit_url'));
$this->grocery_crud->set_relation('customers_id','customers','{lname} {fname}');

Fasil iocod.com

Fasil iocod.com
  • profile picture
  • Member

Posted 29 May 2013 - 05:17 AM

Thanks alot. add this answer to stackoverflow too.. Might be help full for other newbies in grocerycrud. :D  http://stackoverflow.com/questions/16791810/callback-column-not-working-for-connected-table-in-grocery-crud


davidoster

davidoster
  • profile picture
  • Member

Posted 29 May 2013 - 05:20 AM

Thanks for the suggestion!

With a closer look to the forums you would have found this answer. There is already a topic for this ;)