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

      <tfoot id='ZrDDu'></tfoot>
      <legend id='ZrDDu'><style id='ZrDDu'><dir id='ZrDDu'><q id='ZrDDu'></q></dir></style></legend>

      • <bdo id='ZrDDu'></bdo><ul id='ZrDDu'></ul>
    1. <small id='ZrDDu'></small><noframes id='ZrDDu'>

        yii2:在一行中连接多个值的下拉列表

        时间:2023-10-16

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

            <tbody id='X8PE9'></tbody>

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

            <tfoot id='X8PE9'></tfoot>

              <bdo id='X8PE9'></bdo><ul id='X8PE9'></ul>
                • 本文介绍了yii2:在一行中连接多个值的下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  对于我的下拉列表,我正在使用此代码.

                  for my drop-down list I am using this code.

                  <?= $form->field($medicinerequest, '[' . $id . ']' . 'medicine_name')
                  ->DropDownList(ArrayHelper::map(appmodelsMedicine::find()
                  ->asArray()->all(), 'id', 'medicine_name','medicine_id' ),
                  [ 'prompt' => 'Please Select' ])?> 
                  

                  我正在获取如图所示的下拉列表.但我希望它在一行中由连字符 (-) 连接起来.我该怎么做?

                  I am getting the drop-down list as in the picture. But I want it to be concatenated by hyphen(-) in one line. How can I do this?

                  推荐答案

                  ArrayHelper::map($array, $from, $to, $group) 使用 ArrayHelper::getValue() 获取$from$to$group.ArrayHelper::getValue() 允许你传递闭包.

                  ArrayHelper::map($array, $from, $to, $group) uses ArrayHelper::getValue() to obtain the values of $from, $to and $group. ArrayHelper::getValue() allows you to pass closures.

                  匿名函数签名应该是:function($array, $defaultValue).

                  The anonymous function signature should be: function($array, $defaultValue).

                  因此您可以将 $to 设置为

                  As such you can set $to as

                  ArrayHelper::map(
                      appmodelsMedicine::find()->asArray()->all(),
                      'id',
                      function($model) {
                          return $model['medicine_name'].'-'.$model['medicine_id'];
                      }
                  )
                  

                  这篇关于yii2:在一行中连接多个值的下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PHP、Yii2 GridView 过滤关系值 下一篇:Yii2框架如何处理CSRF验证?

                  相关文章

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

                  1. <legend id='3LTDy'><style id='3LTDy'><dir id='3LTDy'><q id='3LTDy'></q></dir></style></legend>
                  2. <small id='3LTDy'></small><noframes id='3LTDy'>

                    <tfoot id='3LTDy'></tfoot>