Files
grecia/app/views/comments/_form.html.erb
Javi Martín 8d9cb4d8e3 Simplify generating checkboxes in forms
Using the block syntax to generate the label with a <span> tag inside
isn't necessary after upgrading foundation_rails_helpers. Before the
upgrade, we couldn't do so because the <span> tag was escaped.
2019-10-06 19:32:04 +02:00

39 lines
1.7 KiB
Plaintext

<% valuation = local_assigns.fetch(:valuation, false) %>
<% cache [locale_and_user_status, parent_id, commentable_cache_key(commentable), valuation] do %>
<% css_id = parent_or_commentable_dom_id(parent_id, commentable) %>
<div id="js-comment-form-<%= css_id %>" <%= "style='display:none'".html_safe if toggeable %> class="comment-form">
<%= form_for Comment.new, remote: true do |f| %>
<%= f.text_area :body,
id: "comment-body-#{css_id}",
maxlength: Comment.body_max_length,
label: leave_comment_text(commentable),
label_options: { for: "comment-body-#{css_id}" } %>
<%= f.hidden_field :commentable_type, value: commentable.class.name %>
<%= f.hidden_field :commentable_id, value: commentable.id %>
<%= f.hidden_field :parent_id, value: parent_id %>
<%= f.hidden_field :valuation, value: valuation %>
<%= f.submit comment_button_text(parent_id, commentable), class: "button", id: "publish_comment" %>
<% if can? :comment_as_moderator, commentable %>
<div class="float-right">
<%= f.check_box :as_moderator,
label: t("comments.form.comment_as_moderator"),
id: "comment-as-moderator-#{css_id}",
label_options: { for: "comment-as-moderator-#{css_id}" } %>
</div>
<% end %>
<% if can? :comment_as_administrator, commentable %>
<div class="float-right">
<%= f.check_box :as_administrator,
label: t("comments.form.comment_as_admin"),
id: "comment-as-administrator-#{css_id}",
label_options: { for: "comment-as-administrator-#{css_id}" } %>
</div>
<% end %>
<% end %>
</div>
<% end %>