• <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 创建下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  <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>