%= render partial: 'shared/form_model_errors', locals: { obj: question} %>
<%= form_for question, url: action do |form| %>
<%= 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) %>
<%= form.label :category, 'Category' %>
<%= form.text_field :category %>
<%= form.label :sort, 'Sort' %>
<%= form.text_field :sort %>
<%= form.check_box :active %>
<%= form.label :active, 'Active' %>
<%= form.label :question, "Question" %>
<%= form.text_area :question %>
<%= form.label :attachment, "Attachment URL" %>
<%= form.text_field :attachment %>
<%= image_tag @question.attachment if @question.attachment.present? %>
<%= form.label :input_type, 'Input Type' %>
<%= form.select :input_type, question_type_options(question.input_type), { include_blank: false }, { data: { qid: question.id } } %>
<%= 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 %>
<%= form.submit %>
<% end %>