skill-assessment-app/app/views/admin/question/_form.html.erb

50 lines
1.4 KiB
Plaintext
Raw Normal View History

2016-08-19 16:02:18 -05:00
<% if flash[:error].present? %>
<div class="error">
<%= flash[:error] %>
<p>
<% question.errors.messages.each do |k,v| %>
<%= "#{k.to_s} #{v.join(' and ')}" %><br />
<% end %>
</p>
</div>
<% end %>
<%= 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 :input_type, 'Input Type' %>
<%= form.select :input_type, question_type_options(question.input_type), include_blank: false %>
</div>
<%= 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 %>