Zend表单和输入按钮

时间:2013-11-05 15:15:29

标签: zend-framework zend-form

我正在尝试向窗体元素添加按钮输入。我希望渲染的代码为<input type="button" ...">我尝试设置attribs字段,如下所示:

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

但我仍然<input type="submit" ...">代替<input type="button" ...">

设置类属性有效,但设置类型不起作用。任何想法得到type =“button”?

2 个答案:

答案 0 :(得分:2)

使用button代替第一个参数,它会为您提供<button> HTML元素(功能与<input type="button" ..>相同)。

答案 1 :(得分:0)

请使用以下代码作为按钮

    $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>
相关问题