Skip to content

Commit 1df1cc8

Browse files
committed
Resolved a problem with embedded mongoid documents and boolean selectors
Previous implementation was creating a label with an incorrect for attribute when used on an embedded mongoid document. It would create <label for=parent_class[embedded_class_attributes]_field_name_1 ... when the id of the input field was parent_class_embedded_class_attributes_field_name_1. Because of this the selectors did nothing when clicked since the label references an id that does not exist. This change to using the rails label helper should safely create the label in all cases.
1 parent 0e12e5b commit 1df1cc8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

app/views/rails_admin/main/_form_boolean.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<div class="btn-group" role="group">
33
<% {'1': [true, 'btn-outline-success'], '0': [false, 'btn-outline-danger'], '': [nil, 'btn-outline-secondary']}.each do |text, (value, btn_class)| %>
44
<%= form.radio_button field.method_name, text, field.html_attributes.reverse_merge({ checked: field.form_value == value, required: field.required, class: 'btn-check' }) %>
5-
<label for="<%= form.object_name %>_<%= field.method_name %>_<%= text %>" class="<%= field.css_classes[value] %> btn <%= btn_class %>">
5+
<%= form.label "#{field.method_name}_#{text}", class: "#{field.css_classes[value]} btn #{btn_class}" do %>
66
<%= field.labels[value].html_safe %>
7-
</label>
7+
<% end %>
88
<% end %>
99
</div>
1010
<% else %>

0 commit comments

Comments
 (0)