<% content_for :title, "Editing '#{@post.title.truncate(50)}'" %>

<% if @post.errors.any? %>
  <div class="notice is-danger">
    These errors prevented this post being saved:
    <ul>
      <% @post.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
    </ul>
  </div>
<% end %>

<h1>Edit <%= @post.policy_doc? ? 'Policy' : (@post.help_doc? ? 'Help Article' : 'Post') %></h1>
<%= form_for @post, url: update_help_post_path(@post) do |f| %>
  <div class="form-group">
    <%= f.label :title, "Title your post:", class: "form-element" %>
    <%= f.text_field :title, class: "form-element" %>
  </div>
  <div class="form-group">
    <%= f.label :body_markdown, 'Body', class: "form-element" %>
    <%= f.text_area :body_markdown, { class: "form-element is-large post-field", rows: 15 } %>
  </div>
  <div class="form-group">
    <%= f.label :help_category, 'Category', class: 'form-element' %>
    <span class="form-caption">
      Name a category under which to display this post in the help center.
    </span>
    <%= f.text_field :help_category, class: 'form-element' %>
  </div>
  <div class="form-group">
    <%= f.label :help_ordering, 'Order', class: 'form-element' %>
    <span class="form-caption">
      Control where this post appears in the list of help articles. Higher values appear later in the list.
    </span>
    <%= f.number_field :help_ordering, class: 'form-element' %>
  </div>
  <%= f.submit "Update", class: "button is-filled is-very-large" %>
<% end %>
