diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index 72f6185a6..3144f6cfe 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -1,6 +1,6 @@ <%= error_messages_for :comment %> -<%= edit_form_for(comment, html: { style: ("display: none;" if local_assigns[:hidden]), class: "edit_comment" }) do |f| %> +<%= edit_form_for(comment, namespace: "post_#{comment.post.id}_comment_#{comment.id || "new"}", html: { style: ("display: none;" if local_assigns[:hidden]), class: "edit_comment" }) do |f| %> <% if comment.new_record? %> <%= f.hidden_field :post_id %> <% end %> diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb index bde646c6e..d95d9c4a2 100644 --- a/config/initializers/simple_form.rb +++ b/config/initializers/simple_form.rb @@ -73,7 +73,13 @@ SimpleForm.setup do |config| # Defaults to :nested for bootstrap config. # inline: input + label # nested: label > input - config.boolean_style = :nested + # + # XXX We use inline instead of nested so that 1) the html structure for + # checkboxes is the same as the html structure of other input elements and 2) + # because if we use the `namespace` option to provide namespaced html IDs on + # a form with nested checkboxes, then SimpleForm generates incorrect IDs on + # the hidden checkbox inputs. + config.boolean_style = :inline # Default class for buttons config.button_class = 'btn'