<% if !commentable && @commentable %> <% commentable = @commentable %> <% end %>
<%= form_for value_for_comment_form(commentable, comment), remote: !comment.new_record?, authenticity_token: true, html: { id: "comment_for_#{commentable.id}" } do |f| %>
<%= t(".legend") %> <% if local_assigns[:show_errors] %> <%= error_messages_for :comment %> <% end %> <%# here come the hacks (hidden fields to transmit various info to the create action) %> <% if commentable.is_a?(Tag) %> <%= hidden_field_tag :tag_id, commentable.name %> <% end %> <% if params[:view_full_work] %> <%= hidden_field_tag :view_full_work, params[:view_full_work] %> <% end %> <% if controller.controller_name == "inbox" && params[:filters] %> <%= hidden_field_tag "filters[read]", params[:filters][:read] %> <%= hidden_field_tag "filters[replied_to]", params[:filters][:replied_to] %> <%= hidden_field_tag "filters[date]", params[:filters][:date] %> <% end %> <% if params[:page] %> <%= hidden_field_tag :page, params[:page] %> <% end %> <% if comments_are_moderated(commentable) && !current_user_is_work_creator(commentable) %>

<% if commentable.is_a?(AdminPost) %> <%= t("comments.commentable.permissions.moderated_commenting.notice.admin_post") %> <% else %> <%= t("comments.commentable.permissions.moderated_commenting.notice.work") %> <% end %>

<% end %> <% if logged_in? %> <% if current_user_is_anonymous_creator(commentable) %>

<%= t(".anonymous_forewarning") %>

<% end %> <% if current_user.pseuds.count > 1 %>

<%= t(".comment_as") %> <%= f.collection_select :pseud_id, current_user.pseuds, :id, :name, { selected: (comment.pseud ? comment.pseud.id.to_s : current_user.default_pseud.id.to_s) }, id: "comment_pseud_id_for_#{commentable.id}", title: t(".choose_name_field_title") %> <% if controller.controller_name == "inbox" %> <%= t(".inbox_reference_html", commentable_creator: commentable.by_anonymous_creator? ? t(".anonymous_creator") : get_commenter_pseud_or_name(commentable), commentable_link: commentable_description_link(commentable)) %> <% end %> (<%= allowed_html_instructions %>)

<% else %>

<%= t(".comment_as") %> <%= f.hidden_field :pseud_id, value: current_user.default_pseud.id.to_s, id: "comment_pseud_id_for_#{commentable.id}" %> <% if controller.controller_name == "inbox" %> <%= t(".inbox_reference_html", commentable_creator: commentable.by_anonymous_creator? ? t(".anonymous_creator") : get_commenter_pseud_or_name(commentable), commentable_link: commentable_description_link(commentable)) %> <% end %>

(<%= allowed_html_instructions %>)

<% end %> <% else %>
<%= t(".landmark.note") %>:
<%= t(".guest_instructions") %>
<%= f.label "name_for_#{commentable.id}", t(".guest_name") %>
<%= f.text_field :name, id: "comment_name_for_#{commentable.id}" %> <%= live_validation_for_field("comment_name_for_#{commentable.id}", failureMessage: t(".guest_name_failure")) %>
<%= f.label "email_for_#{commentable.id}", t(".guest_email") %>
<%= f.text_field :email, id: "comment_email_for_#{commentable.id}" %> <%= live_validation_for_field("comment_email_for_#{commentable.id}", failureMessage: t(".guest_email_failure")) %>

(<%= allowed_html_instructions %>)

<% end %>

<% content_id = "comment_content_for_#{commentable.id}" %> <%= f.text_area :comment_content, id: content_id, class: "comment_form observe_textlength", title: t(".comment_field_title") %>

<%= generate_countdown_html("comment_content_for_#{commentable.id}", ArchiveConfig.COMMENT_MAX) %> <%= live_validation_for_field "comment_content_for_#{commentable.id}", failureMessage: t(".comment_too_short"), maximum_length: ArchiveConfig.COMMENT_MAX, tooLongMessage: t(".comment_too_long", count: ArchiveConfig.COMMENT_MAX) %>

<%= f.submit button_name, id: "comment_submit_for_#{commentable.id}", data: { disable_with: t(".processing_message") } %> <% if controller.controller_name == 'inbox' %> <%= t(".cancel_action") %> <% elsif comment.persisted? %> <%= cancel_edit_comment_link(comment) %> <% elsif commentable.is_a?(Comment) || commentable.is_a?(CommentDecorator) %> <%= cancel_comment_reply_link(commentable) %> <% end %>

<% end %>