moved form errors to partial

This commit is contained in:
Mark Moser 2016-08-19 16:42:06 -05:00
parent 77684b2c3e
commit 8209a2293b
8 changed files with 21 additions and 51 deletions

View File

@ -3,7 +3,7 @@
<ul data-id="input_option_list">
<% question.input_options.each do | option | %>
<li>
<%= text_field_tag 'question[input_options][]', option, { disabled: (disable ||= false), data: { last: option } } %>
<%= text_field_tag 'question[multi_choice][]', option, { disabled: (disable ||= false), data: { last: option } } %>
</li>
<% end %>
</ul>
@ -12,7 +12,7 @@
<div class="form-group">
<div class="btn tertiary-btn" data-id="input_option_adder"> Add option </div>
<li style="display: none;">
<%= text_field_tag 'question[input_options][]', nil, { disabled: (disable ||= false), data: { last: nil } } %>
<%= text_field_tag 'question[multi_choice][]', nil, { disabled: (disable ||= false), data: { last: nil } } %>
</li>
</div>
<% end %>

View File

@ -1,14 +1,4 @@
<% 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 %>
<%= 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' %>

View File

@ -11,17 +11,17 @@
<div data-id="live-coder-answer">
<div class="code-input">
<label for="question_input_options_html">HTML</label>
<%= text_area_tag 'question[input_options][html]', options['html'], { data: {id: 'code-html', last: options['html']}, class: 'code-answer code-html' } %>
<%= text_area_tag 'question[live_code][html]', options['html'], { data: {id: 'code-html', last: options['html']}, class: 'code-answer code-html' } %>
</div>
<div class="code-input">
<label for="question_input_options_css">CSS</label>
<%= text_area_tag 'question[input_options][css]', options['css'], { data: {id: 'code-css', last: options['css']}, class: 'code-answer code-css' } %>
<%= text_area_tag 'question[live_code][css]', options['css'], { data: {id: 'code-css', last: options['css']}, class: 'code-answer code-css' } %>
</div>
<div class="code-input">
<label for="question_input_options_js">JS</label>
<%= text_area_tag 'question[input_options][js]', options['js'], { data: {id: 'code-js', last: options['js']}, class: 'code-answer code-js' } %>
<%= text_area_tag 'question[live_code][js]', options['js'], { data: {id: 'code-js', last: options['js']}, class: 'code-answer code-js' } %>
</div>
<div class="results" data-id="results"></div>

View File

@ -3,7 +3,7 @@
<ul data-id="input_option_list">
<% question.input_options.each do | option | %>
<li>
<%= text_field_tag 'question[input_options][]', option, { disabled: (disable ||= false), data: { last: option } } %>
<%= text_field_tag 'question[multi_choice][]', option, { disabled: (disable ||= false), data: { last: option } } %>
</li>
<% end %>
</ul>
@ -12,7 +12,7 @@
<div class="form-group">
<div class="btn tertiary-btn" data-id="input_option_adder"> Add option </div>
<li style="display: none;">
<%= text_field_tag 'question[input_options][]', nil, { disabled: (disable ||= false), data: { last: nil } } %>
<%= text_field_tag 'question[multi_choice][]', nil, { disabled: (disable ||= false), data: { last: nil } } %>
</li>
</div>
<% end %>

View File

@ -1,14 +1,4 @@
<% if flash[:error].present? %>
<div class="error">
<%= flash[:error] %>
<p>
<% quiz.errors.messages.each do |k,v| %>
<%= "#{k.to_s} #{v.join(' and ')}" %><br />
<% end %>
</p>
</div>
<% end %>
<%= render partial: 'shared/form_model_errors', locals: { obj: quiz} %>
<%= form_for quiz, url: action do |form| %>
<div class="form-group">
<%= form.label :name, "Quiz Description" %>

View File

@ -1,14 +1,4 @@
<% if flash[:error].present? %>
<div class="error">
<%= flash[:error] %>
<p>
<% user.errors.messages.each do |k,v| %>
<%= "#{k.to_s} #{v.join(' and ')}" %><br />
<% end %>
</p>
</div>
<% end %>
<%= render partial: 'shared/form_model_errors', locals: { obj: user} %>
<%= form_for user, url: action do |form| %>
<div class="form-group">
<%= form.label :name, "Full Name" %>

View File

@ -1,17 +1,7 @@
<main class="intro_tpl">
<h1>New Candidate</h1>
<% if flash[:error].present? %>
<div class="error">
<%= flash[:error] %>
<p>
<% @candidate.errors.messages.each do |k,v| %>
<%= "#{k.to_s} #{v.join(' and ')}" %><br />
<% end %>
</p>
</div>
<% end %>
<%= render partial: 'shared/form_model_errors', locals: { obj: @candidate } %>
<%= form_for @candidate, url: create_candidate_path do |form| %>
<div class="form-group">
<%= form.label :name, "Candidate name" %>

View File

@ -0,0 +1,10 @@
<% if flash[:error].present? %>
<div class="error">
<%= flash[:error] %>
<p>
<% obj.errors.messages.each do |k,v| %>
<%= "#{k.to_s} #{v.join(' and ')}" %><br />
<% end %>
</p>
</div>
<% end %>