ZF-11293: Zend_View_Helper_FormReset does not allow empty value attributes.

Description

On our site we do some unique styling of form buttons, resetting the background color, removing borders, using background image attributes via CSS, etc. What we do most is set the label of the element to an empty string '' and then use a background image as the pseudo text/background color. However when using the reset button (Zend_Form_Element_Reset) we noticed that we could not blank out the value of the button. Digging into the code I noticed that the reset button uses Zend_View_Helper_FormReset to render the html. The function signature I believe is not intuitive, just like with the submit button element we should be able to specify an empty value attribute. Additionally on top of this the rendering of the XHTML would have to change as well because as it is now, if an empty string is passed in either through setLabel('') or via setAttrib('value', '') the value attribute is not rendered appropriately.

I created this as a bug because it forces you to have the value of either 'Reset' or whatever the browser agent decides to throw in there if the reset's value attribute is empty.


56c56
<     public function formReset($name = '', $value = null, $attribs = null)
---
>     public function formReset($name = '', $value = 'Reset', $attribs = null)
79,80c79,82
< 
<   $xhtml .= ' value="' . $this->view->escape($value) . '"';
---
>         // add a value if one is given
>         if (! empty($value)) {
>             $xhtml .= ' value="' . $this->view->escape($value) . '"';
>         }

I also did an additional look on w3.org to see if having a value or label for a reset button was mandatory but could not find any documentation supporting this.

Comments

An empty label or a button without a value is the same as a doorbell without a name plate. ;) Set always a text/value for the button and a blind visitors will thank you! (screen reader)

Use CSS:


input[type='reset'] {
    text-indent: -9999px;
    width: 100px;
    background-image: …
}

I would have to disagree. That is why the alt attribute is allowed on input elements for forms. http://www.w3.org/QA/Tips/altAttribute.

Hi Anthony, you're right, but HTML5 brings some changes: [http://whatwg.org/specs/web-apps/…]

Can you add a patch for the current version 1.11? Later, for version 2, we must consider HTML5.

Thanks and greetings Kaiuwe