<%= render partial: 'shared/form_model_errors', locals: { obj: question} %>
<%= form_for question, url: action do |form| %>
  <div class="form-group">
    <%= form.label :quiz_id, 'Quiz' %>
    <%= form.select :quiz_id, options_for_select(@quizzes.map{ |q| [q.name, q.id] }, question.quiz_id), include_blank: (@quizzes.size > 1) %>
  </div>

  <div class="form-group">
    <%= form.label :category, 'Category' %>
    <%= form.text_field :category %>
  </div>

  <div class="form-group">
    <%= form.label :sort, 'Sort' %>
    <%= form.text_field :sort %>
  </div>

  <div class="form-group">
    <%= form.check_box :active %>
    <%= form.label :active, 'Active' %>
  </div>

  <div class="form-group">
    <%= form.label :question, "Question" %>
    <%= form.text_area :question %>
  </div>

  <div class="form-group">
    <%= form.label :attachment, "Attachment URL" %>
    <%= form.text_field :attachment %>

    <% if @question.attachment.present? %>
      <p><%= image_tag @question.attachment %></p>
    <% end %>
  </div>

  <div class="form-group">
    <%= form.label :input_type, 'Input Type' %>
    <%= form.select :input_type, question_type_options(question.input_type), { include_blank: false }, { data: { qid: question.id } } %>
  </div>

  <div class="form-group" data-id="input-options-wrapper">
    <%= fields_for @question do |fields| %>
      <% partial = question.input_type.blank? ? 'admin/question/text' : "admin/question/#{question.input_type}" %>
      <%= render partial: partial, locals: {question: question, fields: fields } %>
    <% end %>
  </div>

  <%= form.submit %>
<% end %>
