【发布时间】: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 字段?
【问题讨论】:
$crud->set_relation('seo_url', 'db_projects','seo');
在 insert/update 上添加 id(主键)从 db_projects 到 seo_url 字段。如何将 db_projects 中的 seo 而不是 id(主键)添加到 seo_url 字段?
【问题讨论】:
对于这种情况,我认为唯一的解决方案是使用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);
【讨论】: