Development

#6579 (sfWidgetFormSchemaFormatter should not set the label for attribute for radio/checkbox lists)

You must first sign up to be able to contribute.

Ticket #6579 (new defect)

Opened 4 years ago

sfWidgetFormSchemaFormatter should not set the label for attribute for radio/checkbox lists

Reported by: logistiker Assigned to: fabien
Priority: minor Milestone:
Component: form Version: 1.2.7
Keywords: Cc:
Qualification: Unreviewed

Description

sfWidgetFormSchemaFormatter should not set the label for attribute for radio/checkbox lists because it references an id that does not exist and is not xhtml compliant. Unfortunately I have to render the form field to determine if it is a radio or checkbox list since it doesn't appear that default attributes are accessible in the symfony core library.

Index: lib/widget/sfWidgetFormSchemaFormatter.class.php
===================================================================
--- lib/widget/sfWidgetFormSchemaFormatter.class.php (revision 18891)
+++ lib/widget/sfWidgetFormSchemaFormatter.class.php (working copy)
@@ -170,7 +170,8 @@
       return '';
     }

-    if (!isset($attributes['for']))
+    $fields = $this->widgetSchema->getFields();
+    if (!isset($attributes['for']) && ($fields[$name]->getOption('choices') === null || ($fields[$name]->getOption('choices') === null && substr($fields[$name]->render(), 0, 6) === '<input'))) {
     {
       $attributes['for'] = $this->widgetSchema->generateId($this->widgetSchema->generateName($name));
     }