Update: Maybe if you try to add an if statement it should work. So in your case perhaps this will work fine for you:
$crud = new grocery_CRUD();
$state_crud = $crud->getState();
if ($state_crud == 'edit' || $state_crud == 'update') {
$crud->callback_edit_field('id_company',array($this,'edit_field_callback_id_company_add'));
} else {
$crud->set_relation('id_company','company','name_company');
}
...
The logic that you are using the callback is wrong. So in your case you need something like this:
$crud->callback_edit_field('id_company',
array($this,'edit_field_callback_id_company_add'));
and then:
function edit_field_callback_id_company_add($value, $primary_key){
$this->db->where('id',$value); //Where id is the primary key for company table
$company = $this->db->get('company')->row();
return '<div id="field-id_company" class="readonly_label">'.$company->name_company.'</div>';
}
There is at the documentation an article that explains how to use callbacks at: http://www.grocerycrud.com/documentation/tutorial_using_callbacks
If you like you can also use the field_type method ( http://www.grocerycrud.com/documentation/options_functions/field_type ) with field_type = readonly
As for the default value functionality there is an issue at github for that: https://github.com/scoumbourdis/grocery-crud/issues/138