<%= simple_form_for [:dashboard, @post] do |f| %> <%= f.error_notification %> <%= hidden_field_tag :type, @post.type_name %> <%= hidden_field_tag 'post[published]', @post.published_at.nil? ? 0 : 1 if Pundit.policy(current_user, @post).publish? %>
<%= f.input :title, autofocus: true %>
<%= f.input :excerpt, required: false %>
<%= f.input :draft_content, as: :text, input_html: { rows: 20, class: "summernote" }, label: "Content" %>
<%= f.association :tags, input_html: { :name => 'post[tag_list][]', class: 'chosen-select', multiple: true } %>
<% if Storytime.enable_file_upload %>
<%= f.input :featured_media_id, as: :hidden, input_html: { id: "featured_media_id" } %>
<%= f.input :secondary_media_id, as: :hidden, input_html: { id: "secondary_media_id" } %>
<% end %> <% if lookup_context.template_exists?("storytime/dashboard/posts/_#{@post.type_name}_fields") %>
<%= render("storytime/dashboard/posts/#{@post.type_name}_fields", f: f) %>
<% end %>
<%= f.input :slug %> <%= f.input :published_at, as: :date_time_picker, input_html: { style: "display: inline" } if @post.published? %>

<% if @post.persisted? %> <%= link_to 'Delete', url_for([:dashboard, @post]), method: :delete, data: { confirm: t('common.are_you_sure_you_want_to_delete', resource_name: @post.human_name) }, class: "btn btn-danger" %> <%= link_to "Preview", post_path(@post, preview: true), class: "btn btn-info", id: "preview_post", target: "_blank" %> <% else %> <% end %> <%= f.submit "Save Draft", class: "btn btn-default save" unless @post.published? %>
<%= f.submit "Publish", class: "btn btn-primary publish", publish: true unless @post.published? %> <%= f.submit "Update", class: "btn btn-default save" if @post.published? %>
<%= f.input :send_subscriber_email, as: :boolean, label: "Notify subscribers of new post" unless @post.published? %>
<% end %> <%= render "storytime/dashboard/media/modal" if Storytime.enable_file_upload %>