• <tfoot id='vh3fW'></tfoot>

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

      <bdo id='vh3fW'></bdo><ul id='vh3fW'></ul>

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

        Zend Framework - 在选择框下拉列表中设置“选定"值

        时间:2023-05-31
          • <bdo id='t2as1'></bdo><ul id='t2as1'></ul>

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

                    <tbody id='t2as1'></tbody>

                1. <legend id='t2as1'><style id='t2as1'><dir id='t2as1'><q id='t2as1'></q></dir></style></legend>
                  <tfoot id='t2as1'></tfoot>

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

                  本文介绍了Zend Framework - 在选择框下拉列表中设置“选定"值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在向 Zend_Form 实例添加一个 select 元素,如下所示:

                  I am adding a select element to a Zend_Form instance as follows:

                    $user = $form->createElement('select','user')->setLabel('User: ')->setRequired(true);
                    foreach($users as $u)
                          {
                              if($selected == $u->id)
                              {
                                  $user->addMultiOption($u->id,$u->firstname.' '.$u->lastname);
                                  //*** some way of setting a selected option? selected="selected"
                  
                              }
                              else
                                  $user->addMultiOption($u->id,$u->firstname.' '.$u->lastname);
                          }
                  

                  我一直在搜索文档,但找不到将选择元素的选项预先设置为已选择"的简单方法.

                  I have been searching the docs but cannot find a simple way of pre-setting an option of the select element to 'selected'.

                  推荐答案

                  我刚刚想出了如何去做.

                  I've just worked out how to do it.

                  必须使用元素的 setValue() 方法:

                  You have to use the setValue() method of the element:

                  $user = $form->createElement('select','user')->setLabel('User: ')->setRequired(true);
                      foreach($users as $u)
                          $user->addMultiOption($u->id,$u->firstname.' '.$u->lastname);
                  
                  $user->setValue($selected); //$selected is the 'value' of the <option> that you want to apply selected="selected" to.
                  

                  这篇关于Zend Framework - 在选择框下拉列表中设置“选定"值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在路由 INI 文件中为 Zend Framework 中的子域编写路由链? 下一篇:如何将 PHP 数组编码为 JSON 数组,而不是对象?

                  相关文章

                2. <small id='7Ij97'></small><noframes id='7Ij97'>

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

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