Reputation: 808
I have a problem with grocery crud hidden field and set relation .
My code is
$crud->set_relation('created_by','users','user_name');
$crud->edit_fields('title', 'description', 'created_by');
$crud->change_field_type('created_by', 'hidden', $this->user_id);
Here i want to store user_id as created by in hidden form. But problem is that created_by field is still visible in my view page. when I cut off set_relation then created_by field is hidden. What's problem ? plz help me
Upvotes: 0
Views: 1150
Reputation: 11
$state = $crud->getState();
if ($state === 'list') {
$crud->set_relation('created_by','users','user_name');
}
$crud->edit_fields('title', 'description', 'created_by');
$crud->change_field_type('created_by', 'hidden', $this->user_id);
Upvotes: 1
Reputation: 872
Use the below coding
$crud->change_field_type('created_by', 'hidden', $this->user_id);
to
$crud->field_type('created_by', 'hidden', $this->user_id);
Upvotes: 0