Skip to content

Commit

Permalink
Added demo application for horizontal form
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam091 committed May 21, 2023
1 parent 26f67ae commit 64f1dcc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
8 changes: 7 additions & 1 deletion demo/app/views/users/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
<%= render partial: "users/form_without_bootstrap_helpers" %>
<% end %>
<%= render partial: "users/vertical_form" %>
<% if false %>
<%= render partial: "users/vertical_form" %>
<% end %>
<% if true %>
<%= render partial: "users/horizontal_form" %>
<% end %>
33 changes: 33 additions & 0 deletions demo/app/views/users/_horizontal_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div class="card card-primary my-3">
<div class="card-header fw-bold">
Profile Form (Horizontal layout)
</div>
<div class="card-body">
<%= bootstrap_form_for @user, bootstrap_form: {layout: :horizontal} do |form| %>
<%= form.text_field :name, autocomplete: "new-name", bootstrap_form: {prepend: "$", append: "0.0"} %>
<%= form.text_field :email, autocomplete: "new-email", bootstrap_form: {} %>
<%= form.text_field :password, autocomplete: "new-password" %>
<%= form.phone_field :mobile_number %>
<%= form.date_field :birth_date %>
<%= form.check_box :terms, bootstrap_form: {switch: false}, required: true %>
<%= form.radio_button :terms, bootstrap_form: {switch: false}, required: true %>
<%= form.range_field :excellence %>
<%= form.url_field :blog_url %>
<%= form.collection_radio_buttons :fruit_id, ::Fruit.all, :id, :name, {bootstrap_form: {inline: true}, checked: form.object.fruit_id} %>
<%= form.color_field :favorite_color %>
<%= form.collection_check_boxes :skill_ids, ::Skill.all, :id, :name, {bootstrap_form: {inline: true}} %>
<%= form.fields_for :address, include_id: false, bootstrap_form: {layout: :horizontal} do |address_form| %>
<%= address_form.text_area :street %>
<%= address_form.text_field :state %>
<%= address_form.grouped_collection_select :city, ::Country.includes(:cities), :cities, :name, :id, :name, {include_blank: "Select city"} %>
<%= address_form.text_field :postal_code %>
<%= address_form.select :country_id, options_for_select(::Country.pluck(:name, :id), address_form.object.country_id),
{include_blank: "Select Country", bootstrap_form: {}} %>
<% end %>
<div class="mt-3">
<%= form.submit "Register", class: "btn btn-primary" %>
<%= link_to "Cancel", users_path, class: "btn btn-secondary" %>
</div>
<% end %>
</div>
</div>

0 comments on commit 64f1dcc

Please sign in to comment.