Issues

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

Issue Type: Bug Created: 2011-04-15T14:46:00.000+0000 Last Updated: 2011-05-13T14:11:56.000+0000 Status: Open Fix version(s): Reporter: Anthony W. (fumanchu182) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_View

Related issues: Attachments:

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.

<pre class="highlight">
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

Posted by Kai Uwe (kaiuwe) on 2011-04-15T16:16:40.000+0000

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:

<pre class="highlight">
input[type='reset'] {
    text-indent: -9999px;
    width: 100px;
    background-image: …
}

Posted by Anthony W. (fumanchu182) on 2011-04-16T17:25:48.000+0000

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.

Posted by Kai Uwe (kaiuwe) on 2011-05-13T14:10:52.000+0000

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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts