Commit ff18e997 authored by marcheing's avatar marcheing

Add school type select helper to profile form

parent 86215906
......@@ -12,4 +12,10 @@ module ProfileHelper
key.zero? ? [occupation, nil] : [occupation, occupation]
end)
end
def school_type_select
options_for_select(I18n.t('school_types').map do |key, school_type|
key.zero? ? [school_type, nil] : [school_type, school_type]
end)
end
end
<div class="form-section">
<%= form_for(profile, 'data-abide' => true, novalidate: true) do |f| %>
<% if profile.errors.any? %>
<div id="error_explanation", data-abide-error class="alert callout">
<h2><p><i class="fa fa-exclamation-circle"></i><%= pluralize(profile.errors.count, 'error') %> prohibited this profile from being saved:</p></h2>
<ul>
<% profile.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<% if profile.errors.any? %>
<div id="error_explanation", data-abide-error class="alert callout">
<h2><p><i class="fa fa-exclamation-circle"></i><%= pluralize(profile.errors.count, 'error') %> prohibited this profile from being saved:</p></h2>
<ul>
<% profile.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<fieldset>
<div class="field-label-item">
......@@ -165,13 +165,8 @@
<div class="field-label">
<%= f.label "#{t('school_type')} *", for: 'user-school-type' %>
</div>
<div class="field-item">
<select id="user-school-type" name="user-school-type">
<option value="">Selecione o tipo de escola</option>
{{#each tipo-escola}}
<option value="{{ id }}">{{ tipo }}</option>
{{/each}}
</select>
<div id="school_fields" class="field-item" style="display:none">
<%= f.select :school_type, school_type_select %>
<span class="form-error">
Campo obrigatório.
</span>
......@@ -180,14 +175,14 @@
<fieldset class="user-school">
<div class="field-label">
<%= f.label "#{t('school')} *", for: 'user-school-name' %>
<%= f.label I18n.t 'school_name', for: 'user-school-name' %>
</div>
<div class="field-item">
<%= f.text_field :school, id: 'user-school-name' %>
<span class="form-error">
Campo obrigatório.
</span>
</div>
</div><br>
</fieldset>
<fieldset>
......
......@@ -33,4 +33,15 @@ describe ProfileHelper, type: :helper do
end
end
end
describe 'school_type_select' do
let!(:school_types) { I18n.t('school_types').values }
let(:result) { helper.school_type_select }
it 'creates options for a select tag with the school types' do
school_types.each do |school_type|
expect(result).to include CGI.escapeHTML school_type
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment