【问题标题】:zend form submit button value not showing in zend formzend 表单提交按钮值未显示在 zend 表单中
【发布时间】:2012-10-01 10:58:12
【问题描述】:

您好,我有一个包含此代码的 zend 表单

$field = new Zend_Form_Element_Submit('submit');
$field->setAttrib('class', 'btn')->setlabel('Save');        

$this->addElement($field);

但是来的html是:

<input type="submit" class="btn" helper="formSubmit" value="" id="submit" name="submit">

不知道为什么值没有显示出来?

【问题讨论】:

    标签: zend-framework zend-form


    【解决方案1】:
    $field->setAttrib('class', 'btn')->setLabel('Save');
    

    请注意上面setLabel()中的大写“L”

    【讨论】:

    • 嗨,rishi,我试过这个代码-&gt;setLabel('Save'),但它仍然没有显示提交中的值。
    • setlabel 和 setLabel 都可以工作,我已经对它们进行了测试(使用您的代码)并且确实可以。您如何显示您的表单或此表单输入?
    • 我的输出没有得到 'helper="formSubmit"' 位,这是从哪里来的?
    【解决方案2】:

    将类型(默认类型=“按钮”不触发表单提交)更改为“提交”。例如

    $this->addElement('button', 'my_button', array(
        'label' => 'Click me',
        'class' => 'nice_button',
        'type' => 'submit'
    ));
    

    【讨论】:

      【解决方案3】:

      您要设置值吗?所以使用setter:$field-&gt;setValue('Save');

      【讨论】:

        猜你喜欢
        • 2013-02-15
        • 1970-01-01
        • 1970-01-01
        • 2011-06-23
        • 2015-09-06
        • 1970-01-01
        • 2018-05-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多