Zend Framework

Radio button getting invalid XHTML label

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.7.8
  • Fix Version/s: 1.9.5
  • Component/s: Zend_Dojo, Zend_Form
  • Labels:
    None

Description

when providing label for the radio buttons an invalid xhtml is created because there is no ID associated with the label form.

Results now:
<dt><label for="gender" class="optional">buggy</label></dt>
<dd><label for="gender-0"><input type="radio" name="gender" id="gender-0" value="0" />0</label><br /><label for="gender-1"><input type="radio" name="gender" id="gender-1" value="1" />1</label></dd>

Should be:
<dt><label class="optional">buggy</label></dt>
<dd><label for="gender-0"><input type="radio" name="gender" id="gender-0" value="0" />0</label><br /><label for="gender-1"><input type="radio" name="gender" id="gender-1" value="1" />1</label></dd>

Activity

Hide
Dennis Day added a comment -

Here is a corrected version by Dennis Day

Show
Dennis Day added a comment - Here is a corrected version by Dennis Day
Hide
Dennis Day added a comment -

I have attached a revised version of FormLabel.php for testing and review.

Show
Dennis Day added a comment - I have attached a revised version of FormLabel.php for testing and review.
Hide
Matthew Weier O'Phinney added a comment -

The patch as provided will not work, as it makes the invalid assumption that the form is assigned to the view as the variable "form".

A better approach would be to modify the FormLabel view helper to allow suppression of the "for" attribute via an options flag, and passing that option from the decorator.

Show
Matthew Weier O'Phinney added a comment - The patch as provided will not work, as it makes the invalid assumption that the form is assigned to the view as the variable "form". A better approach would be to modify the FormLabel view helper to allow suppression of the "for" attribute via an options flag, and passing that option from the decorator.
Hide
Matthew Weier O'Phinney added a comment -

Resolved in trunk and 1.9 release branch.

FormLabel view helper now has a "disableFor" option. If enabled, no "for" attribute will be created. Zend_Form_Element_FormRadio now sets this option by default.

Show
Matthew Weier O'Phinney added a comment - Resolved in trunk and 1.9 release branch. FormLabel view helper now has a "disableFor" option. If enabled, no "for" attribute will be created. Zend_Form_Element_FormRadio now sets this option by default.
Hide
Dennis Day added a comment -

Oops. I tried.

Show
Dennis Day added a comment - Oops. I tried.
Hide
Ernest Szulikowski added a comment -
Show
Ernest Szulikowski added a comment - This fix created another bug: http://framework.zend.com/issues/browse/ZF-8265

People

Vote (5)
Watch (5)

Dates

  • Created:
    Updated:
    Resolved: