【问题标题】:Grocery crud hidden field and set relation didnt work together杂货杂货隐藏字段和设置关系没有一起工作
【发布时间】:2016-01-27 06:38:25
【问题描述】:

我对杂货杂货隐藏字段和设置关系有疑问。

我的代码是

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

在这里,我想以隐藏形式存储由创建的 user_id。但问题是 created_by 字段在我的视图页面中仍然可见。当我切断 set_relation 然后 created_by 字段被隐藏。什么问题 ?请帮帮我

【问题讨论】:

    标签: codeigniter grocery-crud


    【解决方案1】:
    $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);
    

    【讨论】:

    • 你应该考虑添加一些解释性的句子,这会增加你的问题的价值:)
    【解决方案2】:

    使用下面的编码

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

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

    【讨论】:

    • 这个方法不起作用,我有另一个字段被这个 change_field_type 隐藏但只有 created_by 字段不起作用
    猜你喜欢
    • 2013-03-07
    • 1970-01-01
    • 2013-10-24
    • 2016-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多