Skip to content

Commit

Permalink
Use the wrapper_mappings option
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Mar 21, 2014
1 parent de441c5 commit 931c466
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
17 changes: 10 additions & 7 deletions app/views/examples/_basic_example_sf.html.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
<%= simple_form_for :article do |f| %>
<%= simple_form_for :article, wrapper_mappings: {
check_boxes: :vertical_radio_button,
radio_buttons: :vertical_radio_button,
file: :vertical_file_input,
boolean: :vertical_check_box
} do |f| %>
<%= f.input :my_email, as: :string, label: 'Email Address' %>

<%= f.input :my_password, as: :password, label: 'Password' %>

<%= f.input :my_file, as: :file, label: 'File input', wrapper: :vertical_file_input %>
<%= f.input :my_file, as: :file, label: 'File input' %>

<%= f.input :my_checkbox, as: :boolean, label: 'Check me out', :wrapper => :vertical_check_box %>
<%= f.input :my_checkbox, as: :boolean, label: 'Check me out' %>

<%= f.input :my_checkboxes, as: :check_boxes, label: 'This is a checkbox',
collection: ["Option one is this and that—be sure to include why it's great", "Option two can be something else and selecting it will deselect option one"],
wrapper: :vertical_radio_button %>
collection: ["Option one is this and that—be sure to include why it's great", "Option two can be something else and selecting it will deselect option one"] %>

<%= f.input :my_radio_buttons, as: :radio_buttons, label: 'This is a radio button',
collection: ["Option one is this and that—be sure to include why it's great", "Option two can be something else and selecting it will deselect option one"],
wrapper: :vertical_radio_button %>
collection: ["Option one is this and that—be sure to include why it's great", "Option two can be something else and selecting it will deselect option one"] %>

<%= f.button :submit %>
<% end %>
17 changes: 10 additions & 7 deletions app/views/examples/_horizontal_form_sf.html.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
<%= simple_form_for :article, wrapper: :bootstrap_horizontal, html: { class: 'form-horizontal' } do |f| %>
<%= simple_form_for :article, html: { class: 'form-horizontal' }, wrapper: :bootstrap_horizontal, wrapper_mappings: {
check_boxes: :horizontal_radio_button,
radio_buttons: :horizontal_radio_button,
file: :horizontal_file_input,
boolean: :horizontal_check_box
} do |f| %>
<%= f.input :my_email, as: :string, label: 'Email' %>

<%= f.input :my_password, as: :password, label: 'Password' %>

<%= f.input :my_file, as: :file, label: 'File input', wrapper: :horizontal_file_input %>
<%= f.input :my_file, as: :file, label: 'File input' %>

<%= f.input :my_checkbox, as: :boolean, label: 'Remember me', :wrapper => :horizontal_check_box %>
<%= f.input :my_checkbox, as: :boolean, label: 'Remember me' %>

<%= f.input :my_checkboxes, as: :check_boxes, label: 'A couple of checkboxes',
collection: ["Option one is this and that—be sure to include why it's great", "Option two can be something else and selecting it will deselect option one"],
wrapper: :horizontal_radio_button %>
collection: ["Option one is this and that—be sure to include why it's great", "Option two can be something else and selecting it will deselect option one"] %>

<%= f.input :my_radio_buttons, as: :radio_buttons, label: 'A couple of radio button',
collection: ["Option one is this and that—be sure to include why it's great", "Option two can be something else and selecting it will deselect option one"],
wrapper: :horizontal_radio_button %>
collection: ["Option one is this and that—be sure to include why it's great", "Option two can be something else and selecting it will deselect option one"] %>

<%= f.button :submit %>
<% end %>
6 changes: 4 additions & 2 deletions app/views/examples/_inline_form_sf.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<%= simple_form_for :article, defaults: { label: false }, html: { class: 'form-inline' } do |f| %>
<%= simple_form_for :article, defaults: { label: false }, html: { class: 'form-inline' }, wrapper_mappings: {
boolean: :vertical_check_box
} do |f| %>
<%= f.input :email, as: :string, placeholder: 'Email Address' %>

<%= f.input :password, as: :password, placeholder: 'Password' %>

<%= f.input :checkbox, as: :boolean, inline_label: 'Remember me', :wrapper => :vertical_check_box %>
<%= f.input :checkbox, as: :boolean, inline_label: 'Remember me' %>

<%= f.button :submit %>
<% end %>

0 comments on commit 931c466

Please sign in to comment.