Skip to content

Commit

Permalink
Apply bootstrap_form to newly added organization_profile form (#252)
Browse files Browse the repository at this point in the history
* Apply bootstrap_form to newly added organization_profile form

* Add location attributes so bootstrap_form has desired attribute name shown
  • Loading branch information
yuricarvalhop authored Oct 12, 2023
1 parent c26f83b commit d08f790
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
20 changes: 2 additions & 18 deletions app/views/organizations/organization_profiles/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<%= form_with model: profile, :url => organization_profile_path do |form| %>

<%= bootstrap_form_with model: profile, :url => organization_profile_path do |form| %>
<% if profile.errors.count > 0 %>
<div class="alert alert-danger mt-1" role="alert">
<p>
<%= t '.please_fix_the_errors' %>
</p>
<%= t '.please_fix_the_errors' %>
</div>
<% end %>

Expand All @@ -13,30 +10,19 @@
<h3>Contact</h3>

<div class="form-group">
<%= form.label :phone_number, class: 'bigger' %>
<%= form.telephone_field :phone_number,
autofocus: true,
placeholder: "10 digit number",
class: 'form-control' %>

<% profile.errors.full_messages_for(:phone_number).each do |message| %>
<div class="alert alert-danger mt-1" role="alert"><%= message %></div>
<% end %>
</div>

<div class="form-group">
<%= form.label :email %>
<%= form.text_field :email, placeholder: "[email protected]", class: 'form-control' %>

<% profile.errors.full_messages_for(:email).each do |message| %>
<div class="alert alert-danger mt-1" role="alert"><%= message %></div>
<% end %>
</div>

<%# nested form for locations table %>
<div class="form-group bigger" data-controller="country-state">
<%= form.fields_for :location do |location| %>
<%= location.label :country %>
<%= location.select :country,
CS.countries.invert,
{ prompt: "Please select" },
Expand All @@ -50,7 +36,6 @@
<div class="alert alert-danger mt-1" role="alert"><%= error.message %></div>
<% end %>

<%= location.label :province_state, 'Province/State' %>
<%= location.select :province_state,
CS.states(location.object.country).invert,
{ prompt: "Please select" },
Expand All @@ -61,7 +46,6 @@
<div class="alert alert-danger mt-1" role="alert"><%= error.message %></div>
<% end %>

<%= location.label :city_town, 'City/Town' %>
<%= location.text_field :city_town, class: 'form-control' %>
<% profile.location.custom_messages(:city_town).each do |error| %>
<div class="alert alert-danger mt-1" role="alert"><%= error.message %></div>
Expand Down
10 changes: 10 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ en:
submit: "Submit"
status: "Status"
back: "Back"
activerecord:
models:
location: Location
attributes:
location:
country: Country
province_state: Province/State
city_town: City/Town
latitude: Latitude
longitude: Longitude
errors:
attributes:
general:
Expand Down

0 comments on commit d08f790

Please sign in to comment.