简体   繁体   English

如何使用Crud类型的“ relation_hidden”隐藏输入-Codeigniter(Grocery Crud Library)

[英]How can hide input with crud-type “relation_hidden” - Codeigniter (Grocery Crud Library)

I'm using Codeigniter and also Grocery Crud as library. 我正在使用Codeigniter以及Grocery Crud作为库。

The problem apear when i want to hide 1 inputs. 当我想隐藏1个输入时,问题就出现了。 It's about created_by which have set relation. 它与具有设置关系的created_by有关。

All works find with 'crud_type' => 'hidden' . 所有作品都以'crud_type' => 'hidden'

But when you set relation and try to hide it crud_type become relation_hidden . 但是,当你设置的关系,并试图掩盖它crud_type成为relation_hidden All fields with relation_hidden is shown in add page. 所有带有relation_hidden字段都显示在添加页面中。

I have no idea why. 我不知道为什么。 Can someone help me with an advice? 有人可以帮我提建议吗?

I did not manage to hide field which has set_relation , but this workaround might be applicable in your case: 我没有设法隐藏具有set_relation字段,但是这种解决方法可能适用于您的情况:

if( $crud->getstate() == 'edit' ) 
{
    $crud->set_relation('created_by ', 'author', 'author');
}
else
{
    $crud->field_type('created_by ', 'hidden', 'default_value');
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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