• <bdo id='RBj1r'></bdo><ul id='RBj1r'></ul>

      <small id='RBj1r'></small><noframes id='RBj1r'>

    1. <tfoot id='RBj1r'></tfoot><legend id='RBj1r'><style id='RBj1r'><dir id='RBj1r'><q id='RBj1r'></q></dir></style></legend>
    2. <i id='RBj1r'><tr id='RBj1r'><dt id='RBj1r'><q id='RBj1r'><span id='RBj1r'><b id='RBj1r'><form id='RBj1r'><ins id='RBj1r'></ins><ul id='RBj1r'></ul><sub id='RBj1r'></sub></form><legend id='RBj1r'></legend><bdo id='RBj1r'><pre id='RBj1r'><center id='RBj1r'></center></pre></bdo></b><th id='RBj1r'></th></span></q></dt></tr></i><div id='RBj1r'><tfoot id='RBj1r'></tfoot><dl id='RBj1r'><fieldset id='RBj1r'></fieldset></dl></div>

    3. 从相关表 yii 创建下拉列表

      Creating dropdown list from related table yii(从相关表 yii 创建下拉列表)
    4. <small id='CIUCL'></small><noframes id='CIUCL'>

          <tbody id='CIUCL'></tbody>

          <tfoot id='CIUCL'></tfoot>

              • <bdo id='CIUCL'></bdo><ul id='CIUCL'></ul>
                <legend id='CIUCL'><style id='CIUCL'><dir id='CIUCL'><q id='CIUCL'></q></dir></style></legend>
                <i id='CIUCL'><tr id='CIUCL'><dt id='CIUCL'><q id='CIUCL'><span id='CIUCL'><b id='CIUCL'><form id='CIUCL'><ins id='CIUCL'></ins><ul id='CIUCL'></ul><sub id='CIUCL'></sub></form><legend id='CIUCL'></legend><bdo id='CIUCL'><pre id='CIUCL'><center id='CIUCL'></center></pre></bdo></b><th id='CIUCL'></th></span></q></dt></tr></i><div id='CIUCL'><tfoot id='CIUCL'></tfoot><dl id='CIUCL'><fieldset id='CIUCL'></fieldset></dl></div>
              • 本文介绍了从相关表 yii 创建下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有两个表:productproduct_type(与模型相关,分别是 Product 和 Product_type):

                I have two tables: product and product_type (related to the models resp. Product and Product_type):

                product : product_id, product_type_id, name, etc...
                product_type : product_type_id, name, desc, etc...
                

                两者都与键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:

                <?php
                    $list = CHtml::listData(ProductType::model()->findAll(array('order' => 'product_type_name')), 'id', 'id');
                    echo $form->dropDownList($model, 'product_type_id', $list);
                ?>
                

                但它显示空白下拉字段:(

                But it's showing blank dropdown field :(

                我该怎么做?

                推荐答案

                Solved MySelf :)

                Solved MySelf :)

                只需提供 product_type_name.

                By just providing product_type_name.

                <?php
                        $list = CHtml::listData(ProductType::model()->findAll(array('order' => 'product_type_name')), 'product_type_id', 'product_type_name');
                        echo $form->dropDownList($model, 'product_type_id', $list);
                        ?>
                

                这篇关于从相关表 yii 创建下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Appending GET parameters to URL from lt;formgt; action(将 GET 参数附加到来自 lt;formgt; 的 URL行动)
                Forcing quot;Save Asquot; dialog via jQuery GET(强制“另存为通过 jQuery GET 对话框)
                PHP - get certain word from string(PHP - 从字符串中获取某个单词)
                How to debug a get request in php using curl(如何使用 curl 在 php 中调试 get 请求)
                get a # from a url in php(从 php 中的 url 获取 #)
                PHP - include() file not working when variables are put in url?(PHP - 将变量放入 url 时,include() 文件不起作用?)

                  <tbody id='pW48K'></tbody>

                  <i id='pW48K'><tr id='pW48K'><dt id='pW48K'><q id='pW48K'><span id='pW48K'><b id='pW48K'><form id='pW48K'><ins id='pW48K'></ins><ul id='pW48K'></ul><sub id='pW48K'></sub></form><legend id='pW48K'></legend><bdo id='pW48K'><pre id='pW48K'><center id='pW48K'></center></pre></bdo></b><th id='pW48K'></th></span></q></dt></tr></i><div id='pW48K'><tfoot id='pW48K'></tfoot><dl id='pW48K'><fieldset id='pW48K'></fieldset></dl></div>

                  <small id='pW48K'></small><noframes id='pW48K'>

                  <tfoot id='pW48K'></tfoot>
                  • <bdo id='pW48K'></bdo><ul id='pW48K'></ul>
                        • <legend id='pW48K'><style id='pW48K'><dir id='pW48K'><q id='pW48K'></q></dir></style></legend>