Actions
Defect #28447
openfields_for produces a broken <label for=“”> value
Status:
New
Priority:
Normal
Assignee:
-
Category:
UI
Target version:
-
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Affected version:
Description
Here's some code from the redmine_people
plugin illustrating the problem:
<%= f.fields_for :information do |information| >
<p><= information.text_field :middlename, :label => l(:label_people_middlename) ></p>
<p><= f.text_field :lastname, :required => true %></p>
Then one of the fields declares a label:
<p><%= information.select :gender, Person.get_genders, :label => l(:label_people_gender)%></p>
That generates this HTML:
<p><label for="person[information_attributes]_gender">Gender</label>
<select name="person[information_attributes][gender]" id="person_information_attributes_gender">
<option selected="selected" value="0">Male</option>
<option value="1">Female</option>
</select></p>
The <label for="">
value has []
in it instead of underscores _
, so it does not match the target field's id="person_information_attributes_gender"
. Clicking on the label does not put the keyboard focus into that <select>
field.
The bug comes from this statement in LabelledFormBuilder:
@template.content_tag("label", text.html_safe,
:class => (@object && @object.errors[field].present? ? "error" : nil),
:for => (@object_name.to_s + "_" + field.to_s))
The object_name
has []
in it, so something should replace them with "_".
No data to display
Actions