Creating dropdown list from related table yii(从相关表 yii 创建下拉列表)
问题描述
我有两个表:product 和 product_type(与模型相关,分别是 Product 和 Product_type):
I have two tables: product and product_type (related to the models resp. Product and Product_type):
两者都与键product_type_id"相关.
Both are related with key "product_type_id".
我已经使用 gii crud 生成器为两个表创建了 crud.现在在产品表单页面上,我想使用 Yii ActiveRecord 在下拉字段中显示所有 product_type 名称的列表.我在 views/product/_form.php 脚本中添加了这一行:
I have created the crud for both tables using gii crud generator. Now on Product form page I want to display the listing of all product_type name in dropdown field using Yii ActiveRecord. I have added this line in views/product/_form.php script:
但它显示空白下拉字段:(
But it's showing blank dropdown field :(
我该怎么做?
推荐答案
Solved MySelf :)
Solved MySelf :)
只需提供 product_type_name.
By just providing product_type_name.
这篇关于从相关表 yii 创建下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!