• <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 - 在选择框下拉列表中设置“选定"值

        Zend Framework - Set #39;selected#39; value in select box dropdown list(Zend Framework - 在选择框下拉列表中设置“选定值)
          • <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 - 在选择框下拉列表中设置“选定"值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)
                2. <small id='7Ij97'></small><noframes id='7Ij97'>

                        <tbody id='7Ij97'></tbody>
                    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>