-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1004 from plataformatec/rm-bootstrap-3-generator
Update the bootstrap generator to work with Bootstrap 3
- Loading branch information
Showing
5 changed files
with
89 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
=============================================================================== | ||
|
||
Be sure to have a copy of the Bootstrap stylesheet available on your | ||
application, you can get it on http://getbootstrap.com/2.3.2/. | ||
application, you can get it on http://getbootstrap.com/. | ||
|
||
Inside your views, use the 'simple_form_for' with one of the Bootstrap form | ||
classes, '.form-horizontal', '.form-inline', '.form-search' or | ||
'.form-vertical', as the following: | ||
classes, '.form-horizontal' or '.form-inline', as the following: | ||
|
||
= simple_form_for(@user, html: {class: 'form-horizontal' }) do |form| | ||
= simple_form_for(@user, html: { class: 'form-horizontal' }) do |form| | ||
|
||
=============================================================================== |
104 changes: 81 additions & 23 deletions
104
lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,106 @@ | ||
# Use this setup block to configure all options available in SimpleForm. | ||
SimpleForm.setup do |config| | ||
config.error_notification_class = 'alert alert-error' | ||
config.label_class = 'control-label' | ||
config.button_class = 'btn btn-default' | ||
config.boolean_label_class = nil | ||
|
||
config.wrappers :bootstrap, tag: 'div', class: 'control-group', error_class: 'error' do |b| | ||
config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| | ||
b.use :html5 | ||
b.use :placeholder | ||
b.use :label | ||
b.wrapper tag: 'div', class: 'controls' do |ba| | ||
b.use :label, class: 'control-label' | ||
|
||
b.wrapper tag: 'div' do |ba| | ||
ba.use :input, class: 'form-control' | ||
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } | ||
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } | ||
end | ||
end | ||
|
||
config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| | ||
b.use :html5 | ||
b.use :placeholder | ||
b.use :label, class: 'control-label' | ||
|
||
b.wrapper tag: 'div' do |ba| | ||
ba.use :input | ||
ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' } | ||
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } | ||
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } | ||
end | ||
end | ||
|
||
config.wrappers :prepend, tag: 'div', class: "control-group", error_class: 'error' do |b| | ||
config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| | ||
b.use :html5 | ||
b.use :placeholder | ||
b.use :label | ||
b.wrapper tag: 'div', class: 'controls' do |input| | ||
input.wrapper tag: 'div', class: 'input-prepend' do |prepend| | ||
prepend.use :input | ||
end | ||
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' } | ||
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' } | ||
|
||
b.wrapper tag: 'div', class: 'checkbox' do |ba| | ||
ba.use :label_input | ||
end | ||
|
||
b.use :error, wrap_with: { tag: 'span', class: 'help-block' } | ||
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } | ||
end | ||
|
||
config.wrappers :append, tag: 'div', class: "control-group", error_class: 'error' do |b| | ||
config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| | ||
b.use :html5 | ||
b.use :placeholder | ||
b.use :label | ||
b.wrapper tag: 'div', class: 'controls' do |input| | ||
input.wrapper tag: 'div', class: 'input-append' do |append| | ||
append.use :input | ||
b.use :label_input | ||
b.use :error, wrap_with: { tag: 'span', class: 'help-block' } | ||
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } | ||
end | ||
|
||
config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| | ||
b.use :html5 | ||
b.use :placeholder | ||
b.use :label, class: 'col-sm-3 control-label' | ||
|
||
b.wrapper tag: 'div', class: 'col-sm-9' do |ba| | ||
ba.use :input, class: 'form-control' | ||
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } | ||
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } | ||
end | ||
end | ||
|
||
config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| | ||
b.use :html5 | ||
b.use :placeholder | ||
b.use :label, class: 'col-sm-3 control-label' | ||
|
||
b.wrapper tag: 'div', class: 'col-sm-9' do |ba| | ||
ba.use :input | ||
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } | ||
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } | ||
end | ||
end | ||
|
||
config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| | ||
b.use :html5 | ||
b.use :placeholder | ||
|
||
b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr| | ||
wr.wrapper tag: 'div', class: 'checkbox' do |ba| | ||
ba.use :label_input, class: 'col-sm-9' | ||
end | ||
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' } | ||
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' } | ||
|
||
wr.use :error, wrap_with: { tag: 'span', class: 'help-block' } | ||
wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' } | ||
end | ||
end | ||
|
||
config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| | ||
b.use :html5 | ||
b.use :placeholder | ||
|
||
b.use :label, class: 'col-sm-3 control-label' | ||
|
||
b.wrapper tag: 'div', class: 'col-sm-9' do |ba| | ||
ba.use :input | ||
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } | ||
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } | ||
end | ||
end | ||
|
||
# Wrappers for forms and inputs using the Bootstrap toolkit. | ||
# Check the Bootstrap docs (http://getbootstrap.com/2.3.2/) | ||
# Check the Bootstrap docs (http://getbootstrap.com) | ||
# to learn about the different styles for forms and inputs, | ||
# buttons and other elements. | ||
config.default_wrapper = :bootstrap | ||
config.default_wrapper = :vertical_form | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters