⚠ 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

Can I draw 'set_relation' field as readonly?



Kenta Saito

Kenta Saito
  • profile picture
  • Member

Posted 26 April 2012 - 07:05 AM

A 'set_relation' field is drawn as SELECT.
Can I make it readonly? (like Label)


If I set like below:


$this->crud->set_relation(
'auth_user_id',
'auth_users',
'name'
);
$this->crud->change_field_type('auth_user_id', 'readonly');


'auth_users.auth_user_id' will be drawn.
I just wanna draw 'auth_users.name' as Label.

Is there smart way to do this?

Kenta Saito

Kenta Saito
  • profile picture
  • Member

Posted 26 April 2012 - 07:15 AM

I tried like below:


function edit_field_callback_1($value, $primary_key)
{
return $this->db->get_where('auth_users', array('id' => $primary_key))->row()->name;
}


Is there beter way?

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 26 April 2012 - 20:46 PM

For now no, your way is the better way to do it.

Kenta Saito

Kenta Saito
  • profile picture
  • Member

Posted 27 April 2012 - 00:38 AM

OK. Thanks Johnny.

jean-baptiste

jean-baptiste
  • profile picture
  • Member

Posted 13 March 2013 - 16:13 PM

For information, the same trick (using a callback to replace the input field by the read only value of the field) does not work for set_relation_n_n fields : the value of the field is deleted after update.


jean-baptiste

jean-baptiste
  • profile picture
  • Member

Posted 14 March 2013 - 13:02 PM

For documentation, I have found a solution for this problem.