【问题标题】:Zend form and input buttonZend 表单和输入按钮
【发布时间】:2013-11-05 15:15:28
【问题描述】:

我正在尝试将按钮输入添加到表单元素。我希望渲染的代码是<input type="button" ..."> 我尝试像这样设置属性字段:

$this->addElement('submit', 'cancel', array(
                'ignore' => true,
                'label' => 'Anuluj',
                'attribs'=>array('class' => 'class_name', 'type' => 'button')  )
        );

但我仍然得到<input type="submit" ..."> 而不是<input type="button" ...">

设置类属性有效,但设置类型无效。获得 type="button" 的任何想法?

【问题讨论】:

    标签: zend-framework zend-form


    【解决方案1】:

    改为使用button 作为第一个参数,这将为您提供<button> HTML 元素(功能与<input type="button" ..> 相同)。

    【讨论】:

      【解决方案2】:

      请使用以下代码作为按钮

          $this->addElement('button', 'submitted');
          $submitElement = $this->getElement('submitted');
          $submitElement->setAttrib('class',"btn-primary btn");
          $submitElement->setAttrib('value', 'submitted');
          $submitElement->setLabel('SUBMIT');
      

      Html 代码是,

      <button name="submitted" id="submitted" type="button" class="btn-primary btn">SUBMIT</button>
      

      【讨论】:

        猜你喜欢
        • 2017-08-18
        • 2023-03-03
        • 1970-01-01
        • 1970-01-01
        • 2015-05-24
        • 1970-01-01
        • 2015-08-16
        • 2011-01-26
        • 2011-05-18
        相关资源
        最近更新 更多