【问题标题】:Grocery crud set_relation杂货杂货 set_relation
【发布时间】:2013-02-03 13:17:21
【问题描述】:
$crud->set_relation('seo_url', 'db_projects','seo');

insert/update 上添加 id(主键)从 db_projects 到 seo_url 字段。如何将 db_projects 中的 seo 而不是 id(主键)添加到 seo_url 字段?

【问题讨论】:

    标签: codeigniter grocery-crud


    【解决方案1】:

    对于这种情况,我认为唯一的解决方案是使用field_type 方法实际创建一个自定义下拉列表。因此,在您的情况下,您将拥有:

    $seo_results = array();
    foreach ($this->db->get('db_projects')->result() as $row) {
        $seo_results[$row->seo] = $row->seo;
    } 
    $crud->field_type('seo_url', 'dropdown', $seo_results);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多