简体   繁体   中英

Grocery crud hidden field and set relation didnt work together

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

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

Use the below coding

$crud->change_field_type('created_by', 'hidden', $this->user_id);

to

$crud->field_type('created_by', 'hidden', $this->user_id);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM