⚠ 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 forum is read-only and soon will be archived. ⚠


callback_column not working for connected tables

callback_column set_relation grocerycrud

  • Please log in to reply
3 replies to this topic

#1 Fasil iocod.com

Fasil iocod.com

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 28 May 2013 - 01: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??



#2 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts

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}');


#3 Fasil iocod.com

Fasil iocod.com

    Newbie

  • Members
  • Pip
  • 7 posts

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...in-grocery-crud



#4 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts

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 ;)







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users