[英]set_relation not working in grocery crud
I have a controller like this: 我有一个像这样的控制器:
function index()
{
$crud = new grocery_CRUD();
$crud->set_relation('name','parttype','type');
$crud->set_table('part');
$crud->set_subject('Items');
$output = $crud->render();
$this->_example_output($output);
}
I expected a dropdown field on the ADD/EDIT screens for the field "type" and for that dropdown to have options populated from parttypes table. 我希望在“添加/编辑”屏幕上为“类型”字段添加一个下拉字段,并且该下拉菜单具有从零件类型表中填充的选项。 But this code just returns text fields.
但是此代码仅返回文本字段。
Here are my tables: 这是我的桌子:
PARTTYPE TABLE 零件表
id -int,autocrement id -int,autocrement
name - varchar (500) 名称-varchar(500)
furl - varchar(500) furl-varchar(500)
PART TABLE 零件表
id -int,autocrement id -int,autocrement
name - varchar (500) 名称-varchar(500)
type - varchar(500) 类型-varchar(500)
model - varchar (500) 型号-varchar(500)
可能您做错了,我认为您正在寻找的解决方案是:
$crud->set_relation('type','parttype','name');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.