coopdevs/timeoverflow

View on GitHub
app/views/shared/_post_form.html.erb

Summary

Maintainability
Test Coverage
<%= show_error_messages! post %>
<%= form_for post, html: { name: "form", novalidate: true } do |f| %>
  <div class="form-group">
    <%= f.label :title, required: true %>
    <%= f.text_field :title, class: "form-control" %>
  </div>
  <div class="form-group">
    <%= f.label :description %>
    <%= f.text_area :description, rows: "10", class: "form-control" %>
    <p class="small text-right">
      <%= t ".you_can_use" %>
      <a href="https://<%= I18n.locale %>.wikipedia.org/wiki/Markdown" title="Markdown">Markdown</a>
    </p>
  </div>
  <div class="form-group">
    <%= f.label :category, required: true %>
    <%= f.select :category_id, categories_for_select, { include_blank: true }, class: "form-control" %>
  </div>
  <div class="form-group">
    <%= label :post, :is_group, I18n.t("shared.post_form.group_#{post.class.name.downcase}"), required: true %>
    <%= f.check_box :is_group, class: 'inline-checkbox' %>
  </div>
  <div class="form-group">
    <%= f.label :tag_list %>
    <%= f.select :tag_list,
                 f.object.tags || [],
                 { selected: f.object.tags },
                 multiple: true,
                 data: { placeholder: t("application.tips.entertag"), model: "post" },
                 id: "tags-js",
                 class: "form-control" %>
  </div>
  <% if current_user.manages?(current_organization) %>
    <div class="form-group">
      <%= f.label :user, class: "control-label" %>
      <%= f.select :user_id,
                   members_for_select(post),
                   {},
                   id: "select2",
                   class: "form-control",
                   required: true %>
    </div>
  <% end %>
  <%= f.button label_button, class: "btn btn-default" %>
<% end %>