bootstrap_form 2.7.0 → 4.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +14 -0
- data/.travis.yml +29 -0
- data/CHANGELOG.md +227 -0
- data/CONTRIBUTING.md +57 -0
- data/Dangerfile +54 -0
- data/Gemfile +21 -0
- data/{MIT-LICENSE → LICENSE.txt} +1 -1
- data/README.md +154 -87
- data/Rakefile +5 -15
- data/UPGRADE-4.0.md +79 -0
- data/bootstrap_form.gemspec +28 -0
- data/demo/README.md +17 -0
- data/demo/Rakefile +6 -0
- data/demo/app/controllers/application_controller.rb +2 -0
- data/demo/app/controllers/bootstrap_controller.rb +16 -0
- data/demo/app/helpers/bootstrap_helper.rb +23 -0
- data/{test/dummy → demo}/app/models/address.rb +0 -0
- data/demo/app/models/application_record.rb +3 -0
- data/{test/dummy → demo}/app/models/faux_user.rb +0 -0
- data/{test/dummy → demo}/app/models/super_user.rb +0 -0
- data/{test/dummy → demo}/app/models/user.rb +0 -0
- data/demo/app/views/bootstrap/form.html.erb +53 -0
- data/demo/app/views/layouts/application.html.erb +65 -0
- data/demo/bin/bundle +3 -0
- data/{test/dummy → demo}/bin/rails +1 -1
- data/{test/dummy → demo}/bin/rake +0 -0
- data/demo/bin/setup +36 -0
- data/demo/bin/update +31 -0
- data/demo/bin/yarn +11 -0
- data/{test/dummy → demo}/config.ru +2 -1
- data/demo/config/application.rb +24 -0
- data/demo/config/boot.rb +5 -0
- data/{test/dummy → demo}/config/database.yml +8 -12
- data/demo/config/environment.rb +5 -0
- data/demo/config/environments/development.rb +60 -0
- data/{test/dummy → demo}/config/environments/test.rb +15 -20
- data/demo/config/initializers/application_controller_renderer.rb +8 -0
- data/demo/config/initializers/assets.rb +14 -0
- data/{test/dummy → demo}/config/initializers/backtrace_silencers.rb +0 -0
- data/demo/config/initializers/cookies_serializer.rb +5 -0
- data/{test/dummy → demo}/config/initializers/filter_parameter_logging.rb +0 -0
- data/{test/dummy → demo}/config/initializers/inflections.rb +0 -0
- data/{test/dummy → demo}/config/initializers/mime_types.rb +0 -1
- data/{test/dummy → demo}/config/initializers/wrap_parameters.rb +2 -2
- data/{test/dummy → demo}/config/locales/en.yml +10 -0
- data/demo/config/puma.rb +56 -0
- data/{test/dummy → demo}/config/routes.rb +2 -0
- data/demo/config/spring.rb +6 -0
- data/demo/config/storage.yml +35 -0
- data/demo/db/schema.rb +24 -0
- data/{test/dummy/public/favicon.ico → demo/log/.keep} +0 -0
- data/demo/package.json +5 -0
- data/demo/public/favicon.ico +0 -0
- data/lib/bootstrap_form/form_builder.rb +221 -96
- data/lib/bootstrap_form/helper.rb +26 -16
- data/lib/bootstrap_form/helpers/bootstrap.rb +37 -24
- data/lib/bootstrap_form/version.rb +1 -1
- metadata +67 -252
- data/lib/bootstrap_form/helpers/nested_form.rb +0 -33
- data/test/bootstrap_checkbox_test.rb +0 -144
- data/test/bootstrap_fields_test.rb +0 -152
- data/test/bootstrap_form_group_test.rb +0 -289
- data/test/bootstrap_form_test.rb +0 -209
- data/test/bootstrap_other_components_test.rb +0 -86
- data/test/bootstrap_radio_button_test.rb +0 -124
- data/test/bootstrap_selects_test.rb +0 -160
- data/test/dummy/Gemfile +0 -45
- data/test/dummy/Gemfile.lock +0 -120
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -10
- data/test/dummy/app/assets/javascripts/application.js +0 -16
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/config/application.rb +0 -23
- data/test/dummy/config/boot.rb +0 -4
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -29
- data/test/dummy/config/environments/production.rb +0 -80
- data/test/dummy/config/initializers/secret_token.rb +0 -12
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/db/migrate/20130703191909_create_users.rb +0 -13
- data/test/dummy/db/migrate/20130703191937_create_addresses.rb +0 -13
- data/test/dummy/db/migrate/20130912171202_add_preferences_to_user.rb +0 -5
- data/test/dummy/db/migrate/20140327190145_add_terms_to_user.rb +0 -5
- data/test/dummy/db/migrate/20140922133133_add_type_to_users.rb +0 -5
- data/test/dummy/db/schema.rb +0 -39
- data/test/dummy/db/seeds.rb +0 -7
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +0 -38160
- data/test/dummy/public/404.html +0 -58
- data/test/dummy/public/422.html +0 -58
- data/test/dummy/public/500.html +0 -57
- data/test/dummy/public/robots.txt +0 -5
- data/test/dummy/test/fixtures/addresses.yml +0 -15
- data/test/dummy/test/fixtures/users.yml +0 -15
- data/test/dummy/test/models/address_test.rb +0 -7
- data/test/dummy/test/models/user_test.rb +0 -7
- data/test/dummy/test/test_helper.rb +0 -15
- data/test/special_form_class_models_test.rb +0 -43
- data/test/test_helper.rb +0 -86
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8eb7cf943e5416aff7a98a51666bee424be65eec12c55244a327c88d21a6d68d
|
4
|
+
data.tar.gz: 1ef48e511095bbab5bbef27ec4542019872f25fd5504834e51b1a253fd6dc1bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4022101ea8932a6ad3198cb9b517e65db477203633cbc31b9db4cb554ebf90cb73745ba4fe4f80dd3a5aca272a5ee92d18fc8955d391ece5e7eb6899f43600af
|
7
|
+
data.tar.gz: 5536da85294e55e980ed267576f84433e3adca060ecaad50594b7e600b9bb5d49a414ab75c559bb841e04f0ac1f336b24a64a0aaa05501f9e947e8e138a7d2cc
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.2.9
|
4
|
+
- 2.3.6
|
5
|
+
- 2.4.3
|
6
|
+
- 2.5.0
|
7
|
+
gemfile:
|
8
|
+
- test/gemfiles/5.0.gemfile
|
9
|
+
- test/gemfiles/5.1.gemfile
|
10
|
+
- test/gemfiles/5.2.gemfile
|
11
|
+
before_install:
|
12
|
+
- gem update --system
|
13
|
+
- gem install bundler --no-document
|
14
|
+
|
15
|
+
matrix:
|
16
|
+
include:
|
17
|
+
# Bleeding edge
|
18
|
+
- rvm: ruby-head
|
19
|
+
gemfile: test/gemfiles/5.2.gemfile
|
20
|
+
|
21
|
+
# Running one job to execute DANGER bot
|
22
|
+
- rvm: 2.5.0
|
23
|
+
gemfile: test/gemfiles/5.2.gemfile
|
24
|
+
script:
|
25
|
+
- gem install danger
|
26
|
+
- danger
|
27
|
+
|
28
|
+
allow_failures:
|
29
|
+
- rvm: ruby-head
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
## [Pending Release][]
|
2
|
+
|
3
|
+
### Breaking changes
|
4
|
+
|
5
|
+
* Your contribution here!
|
6
|
+
|
7
|
+
### New features
|
8
|
+
|
9
|
+
* Your contribution here!
|
10
|
+
|
11
|
+
### Bugfixes
|
12
|
+
|
13
|
+
* Your contribution here!
|
14
|
+
|
15
|
+
|
16
|
+
## [4.0.0.alpha1][] (2018-06-16)
|
17
|
+
|
18
|
+
🚨 **This release adds support for Bootstrap v4 and drops support for Bootstrap v3.** 🚨
|
19
|
+
|
20
|
+
If your app uses Bootstrap v3, you should continue using bootstrap_form 2.7.x instead.
|
21
|
+
|
22
|
+
Bootstrap v3 and v4 are very different, and thus bootstrap_form now produces different markup in order to target v4. The changes are too many to list here; you can refer to Bootstrap's [Migrating to v4](https://getbootstrap.com/docs/4.0/migration/) page for a detailed explanation.
|
23
|
+
|
24
|
+
In addition to these necessary markup changes, the bootstrap_form API itself has the following important changes in this release.
|
25
|
+
|
26
|
+
### Breaking changes
|
27
|
+
|
28
|
+
* Rails 4.x is no longer supported
|
29
|
+
* Ruby 2.2 or newer is required
|
30
|
+
* Built-in support for the `nested_form` gem has been completely removed
|
31
|
+
* The `icon` option is no longer supported (Bootstrap v4 does not include icons)
|
32
|
+
* The deprecated Rails methods `check_boxes_collection` and `radio_buttons_collection` have been removed
|
33
|
+
* `hide_label: true` and `skip_label: true` on individual check boxes and radio buttons apply Bootstrap 4 markup. This means the appearance of a page may change if you're upgrading from the Bootstrap 3 version of `bootstrap_form`, and you used `check_box` or `radio_button` with either of those options
|
34
|
+
* `static_control` will no longer properly show error messages. This is the result of bootstrap changes.
|
35
|
+
* `static_control` will also no longer accept a block, use the `value` option instead.
|
36
|
+
* `form_group` with a block that produces arbitrary text needs to be modified to produce validation error messages (see the UPGRADE-4.0 document). [@lcreid](https://github.com/lcreid).
|
37
|
+
* `form_group` with a block that contains more than one `check_box` or `radio_button` needs to be modified to produce validation error messages (see the UPGRADE-4.0 document). [@lcreid](https://github.com/lcreid).
|
38
|
+
* [#456](https://github.com/bootstrap-ruby/bootstrap_form/pull/456): Fix label `for` attribute when passing non-english characters using `collection_check_boxes` - [@ug0](https://github.com/ug0).
|
39
|
+
* [#449](https://github.com/bootstrap-ruby/bootstrap_form/pull/449): Bootstrap 4 no longer mixes in `.row` in `.form-group`. `bootstrap_form` adds `.row` to `div.form-group` when layout is horizontal.
|
40
|
+
|
41
|
+
### New features
|
42
|
+
|
43
|
+
* Support for Rails 5.1 `form_with` - [@lcreid](https://github.com/lcreid).
|
44
|
+
* Support Bootstrap v4's [Custom Checkboxes and Radios](https://getbootstrap.com/docs/4.0/components/forms/#checkboxes-and-radios-1) with a new `custom: true` option
|
45
|
+
* Allow HTML in help translations by using the `_html` suffix on the key - [@unikitty37](https://github.com/unikitty37)
|
46
|
+
* [#408](https://github.com/bootstrap-ruby/bootstrap_form/pull/408): Add option[:id] on static control #245 - [@duleorlovic](https://github.com/duleorlovic).
|
47
|
+
* [#455](https://github.com/bootstrap-ruby/bootstrap_form/pull/455): Support for i18n `:html` subkeys in help text - [@jsaraiva](https://github.com/jsaraiva).
|
48
|
+
* Adds support for `label_as_placeholder` option, which will set the label text as an input fields placeholder (and hiding the label for sr_only).
|
49
|
+
* [#449](https://github.com/bootstrap-ruby/bootstrap_form/pull/449): Passing `.form-row` overrides default `.form-group.row` in horizontal layouts.
|
50
|
+
* Added an option to the `submit` (and `primary`, by transitivity) form tag helper, `render_as_button`, which when truthy makes the submit button render as a button instead of an input. This allows you to easily provide further styling to your form submission buttons, without requiring you to reinvent the wheel and use the `button` helper (and having to manually insert the typical Bootstrap classes). - [@jsaraiva](https://github.com/jsaraiva).
|
51
|
+
* Add `:error_message` option to `check_box` and `radio_button`, so they can output validation error messages if needed. [@lcreid](https://github.com/lcreid).
|
52
|
+
|
53
|
+
### Bugfixes
|
54
|
+
|
55
|
+
* [#357](https://github.com/bootstrap-ruby/bootstrap_form/pull/357) if provided,
|
56
|
+
use html option `id` to specify `for` attribute on label
|
57
|
+
[@duleorlovic](https://github.com/duleorlovic)
|
58
|
+
|
59
|
+
|
60
|
+
## [2.7.0][] (2017-04-21)
|
61
|
+
|
62
|
+
Features:
|
63
|
+
* [#325](https://github.com/bootstrap-ruby/bootstrap_form/pull/325): Support :prepend and :append for the `select` helper - [@donv](https://github.com/donv).
|
64
|
+
|
65
|
+
## [2.6.0][] (2017-02-03)
|
66
|
+
|
67
|
+
Bugfixes:
|
68
|
+
- Fix ambiguous first argument warning (#311, @mikenicklas)
|
69
|
+
|
70
|
+
Features:
|
71
|
+
- Add a FormBuilder#custom_control helper [#289](https://github.com/bootstrap-ruby/bootstrap_form/pull/289)
|
72
|
+
|
73
|
+
## [2.5.3][] (2016-12-23)
|
74
|
+
|
75
|
+
There are no user-facing changes with this release. Behind the scenes, the tests have been greatly improved. The project is now tested against and compatible with the following Rails versions 4.0, 4.1, 4.2 and 5.0 (#278).
|
76
|
+
|
77
|
+
## [2.5.2][] (2016-10-08)
|
78
|
+
|
79
|
+
Bugfixes:
|
80
|
+
- Allow objects without `model_name`s to act as form objects (#295, @laserlemon)
|
81
|
+
- Fix offset for submit for horizontal forms when using non-sm column breakers for label column (#293, @oteyatosys)
|
82
|
+
|
83
|
+
## [2.5.1][] (2016-09-23)
|
84
|
+
|
85
|
+
Bugfixes:
|
86
|
+
- Fix getting help text for elements when using anonymous models (see [issue 282](https://github.com/bootstrap-ruby/bootstrap_form/issues/282))
|
87
|
+
|
88
|
+
## [2.5.0][] (2016-08-12)
|
89
|
+
|
90
|
+
Bugfixes:
|
91
|
+
|
92
|
+
- Sanitize <label> name (IE `for` attribute) in same manner that Rails sanitizes
|
93
|
+
the <input> `id` attribute to fix a11y issue with `for` and `id` mismatch
|
94
|
+
- Fix loading of ActionView helpers in combination with RSpec and `rails-controller-testing`. (see [rails-controller-testing/issues#24](https://github.com/rails/rails-controller-testing/issues/24))
|
95
|
+
|
96
|
+
Features:
|
97
|
+
|
98
|
+
- Add support for input-group-sm and input-group-lg in prepend/append (#226, @rusanu)
|
99
|
+
- Added option to prevent the 'required' CSS class on labels (#205, @LucasAU)
|
100
|
+
|
101
|
+
## [2.4.0][] (2016-07-04)
|
102
|
+
|
103
|
+
This version is ready to use with Rails 5.0.0!
|
104
|
+
|
105
|
+
Bugfixes:
|
106
|
+
|
107
|
+
- Minor README corrections (#184, @msmithstubbs)
|
108
|
+
- Fix `alias_method_chain` deprecation warnings when using Rails 5
|
109
|
+
- Allow `form_group` to work with frozen string options
|
110
|
+
|
111
|
+
Features:
|
112
|
+
|
113
|
+
- Allow primary button classes to be overridden (#183, @tanimichi)
|
114
|
+
- Allow to pass a block to select helper in Rails >= 4.1.0 (#229, @doits)
|
115
|
+
|
116
|
+
## 2.3.0 (2015-02-17)
|
117
|
+
|
118
|
+
Bugfixes:
|
119
|
+
|
120
|
+
- Use #underscore, not #downcase for help text scope (#140, @atipugin)
|
121
|
+
- Radio button and checkbox labels will now include the disabled class as needed. (#156, @ScottSwezey)
|
122
|
+
- Fixed issue with setting offset in form_group without label in horizontal layout
|
123
|
+
when form uses non-default label_col
|
124
|
+
- Fixed wrapper options (#153, @veilleperso)
|
125
|
+
- Fix errors on non-ActiveRecord setups (#200, @sgnn7)
|
126
|
+
|
127
|
+
Features:
|
128
|
+
|
129
|
+
- Allow users to display validation errors in labels (#144, @timcheadle)
|
130
|
+
- Use humanized attribute name in label errors (#146, @atipugin)
|
131
|
+
- Allow to skip label rendering (#145, @atipugin)
|
132
|
+
- Added a `required` CSS class for labels with required attributes (#150, @krsyoung)
|
133
|
+
- Added option to customize labels' class.
|
134
|
+
- Allow callable value_method and text_method for collection_check_boxes and collection_radio_buttons (#199, @shadwell)
|
135
|
+
|
136
|
+
## 2.2.0 (2014-09-16)
|
137
|
+
|
138
|
+
Bugfixes:
|
139
|
+
|
140
|
+
- Fixed an exception raised when form_group block returns nil (#111)
|
141
|
+
- Fixed an exception on human_attribute_name when using bootstrap_form_tag (#115)
|
142
|
+
- Set offset in form_group without label in horizontal layout (#94, @datWav)
|
143
|
+
- Fixes an offset bug in form_group without a given label in horizontal layout (#130, @datWav)
|
144
|
+
- Fixed bug where collection_check_boxes doesn't work if all are unchecked (#116, @burnt43)
|
145
|
+
|
146
|
+
Features:
|
147
|
+
|
148
|
+
- Added the ability to append/prepend buttons (@retoo)
|
149
|
+
- Added support for time_zone_select
|
150
|
+
- Accept multiple values, and objects as well, on `collection_check_boxes`
|
151
|
+
checked option (#114)
|
152
|
+
- Added support for hidding attribute name in errors_on helper (@datWav)
|
153
|
+
- Added support for additional class to the wrapper form_group by a field (@datWav)
|
154
|
+
- Support showing error summaries when inline_errors is enabled (@rosswilson)
|
155
|
+
- Name is now optional when creating static controls
|
156
|
+
- Keep original form helper methods with _without_bootstrap suffix (#123, @a2ikm)
|
157
|
+
- Added glyphicon support
|
158
|
+
- Added i18n support for help messages (#122, @huynhquancam)
|
159
|
+
- Added the ability to pass any attributes to wrapper (#136, @atipugin)
|
160
|
+
- Split monolithic test file into several smaller files (#141, @spacewander)
|
161
|
+
- Added role="form" attribute to forms (#142, @spacewander)
|
162
|
+
|
163
|
+
## 2.1.1 (2014-04-20)
|
164
|
+
|
165
|
+
Bugfixes:
|
166
|
+
|
167
|
+
- Do not reset additional classes on the form-group (@rzane)
|
168
|
+
- Fixed an exception when specifying a label while using bootstrap_form_tag
|
169
|
+
|
170
|
+
Features:
|
171
|
+
|
172
|
+
- [nested_form](https://github.com/ryanb/nested_form) integration via
|
173
|
+
`bootstrap_nested_form_for` (#44 and #66)
|
174
|
+
- `form_group` no longer requires a name (#83)
|
175
|
+
|
176
|
+
## 2.1.0 (2014-04-01)
|
177
|
+
|
178
|
+
Moved GitHub repository from https://github.com/potenza/bootstrap_form
|
179
|
+
to https://github.com/bootstrap-ruby/bootstrap_form
|
180
|
+
|
181
|
+
Bugfixes:
|
182
|
+
|
183
|
+
- i18n fix for checkbox labels (@i10a)
|
184
|
+
- Wrapped date & time helpers inside control-specific css classes to prevent stacking
|
185
|
+
- control-label class was not being added unless the form was horizontal (@slave2zeros)
|
186
|
+
- selects & collection selects were dropping label options
|
187
|
+
- allow html content in check_box tag label (@desheikh)
|
188
|
+
- allow check_box label to be defined with a block
|
189
|
+
- omit form-control class from file_field (@mbrictson)
|
190
|
+
- Collection inputs honour `checked` attribute (@desheikh)
|
191
|
+
- Fixing label/input pairing for checkbox collections (@byped)
|
192
|
+
- Removing for attribute on radio button labels (@sigmike)
|
193
|
+
|
194
|
+
Features:
|
195
|
+
|
196
|
+
- The control_class can be overridden per field by passing in the
|
197
|
+
:control_class option. Default value is "form-control".
|
198
|
+
- Make name optional in FormBuilder#submit (@adrpac)
|
199
|
+
- Added the FormBuilder#primary helper back in
|
200
|
+
- Added a FormBuilder#static_control helper
|
201
|
+
- Added support for radio_buttons_collection and check_boxes_collection
|
202
|
+
- Added a FormBuilder#error_summary helper method
|
203
|
+
- inline_errors can be turned off: bootstrap_form_for(obj, inline_errors: false)
|
204
|
+
When inline errors are off, FormBuilder#alert_message contains the error summary.
|
205
|
+
This can also be turned off with the option 'error_summary: false'
|
206
|
+
- Added support for: color_field, date_field, datetime_field, datetime_local_field,
|
207
|
+
month_field, range_field, search_field (#42), time_field, week_field
|
208
|
+
- Added ability to override the left/right classes for a particular control
|
209
|
+
when using horizontal forms. (@baldwindavid)
|
210
|
+
- Added support for grouped_collection_select (@rzane)
|
211
|
+
- Added support of Rails 4 syntax for collection inputs (@desheikh)
|
212
|
+
- Renamed options :left to :label_col and :right to :control_col
|
213
|
+
- Renamed option :style to :layout (@baldwindavid)
|
214
|
+
- Added errors_on helper (@baldwindavid)
|
215
|
+
- Added per field layout option (@baldwindavid)
|
216
|
+
- Added support for bootstrap_form_tag (@baldwindavid)
|
217
|
+
|
218
|
+
|
219
|
+
[Pending Release]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v4.0.0.alpha1...HEAD
|
220
|
+
[4.0.0.alpha1]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v2.7.0...v4.0.0.alpha1
|
221
|
+
[2.7.0]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v2.6.0...v2.7.0
|
222
|
+
[2.6.0]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v2.5.3...v2.6.0
|
223
|
+
[2.5.3]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v2.5.2...v2.5.3
|
224
|
+
[2.5.2]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v2.5.1...v2.5.2
|
225
|
+
[2.5.1]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v2.5.0...v2.5.1
|
226
|
+
[2.5.0]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v2.4.0...v2.5.0
|
227
|
+
[2.4.0]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v2.3.0...v2.4.0
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
The release of Bootstrap 4 and Rails 5.1 have implications for the future
|
4
|
+
direction of `bootstrap_form`. Don't worry. We plan to move this gem forward to
|
5
|
+
Bootstrap 4 and to support Rails 5.1 and beyond. If you're thinking of
|
6
|
+
contributing to `bootstrap_form`, please read
|
7
|
+
[issue #361](https://github.com/bootstrap-ruby/bootstrap_form/issues/361).
|
8
|
+
|
9
|
+
Your comments are welcome.
|
10
|
+
|
11
|
+
Thanks so much for considering a contribution to bootstrap_form. We love pull requests!
|
12
|
+
|
13
|
+
Here's a quick guide for contributing:
|
14
|
+
|
15
|
+
### 1. Check if issue or feature is available to work on
|
16
|
+
|
17
|
+
Make sure no one else is working on the same issue or feature. Search the issues
|
18
|
+
and pull requests for anything that looks like the issue or feature you want to
|
19
|
+
address. If no one else is working on your issue or feature, carry on with the
|
20
|
+
following steps.
|
21
|
+
|
22
|
+
### 2. Fork the repo
|
23
|
+
|
24
|
+
For the project. Optionally, create a branch you want to work on
|
25
|
+
|
26
|
+
### 3. Get it running locally
|
27
|
+
|
28
|
+
- Install the required dependencies with `bundle install`
|
29
|
+
- Run tests via: `bundle exec rake`
|
30
|
+
|
31
|
+
### 4. Hack away
|
32
|
+
|
33
|
+
- Try to keep your changes small. Consider making several smaller pull requests.
|
34
|
+
- Don't forget to add necessary tests.
|
35
|
+
- Update the README if necessary.
|
36
|
+
- Add a line to the CHANGELOG for your bug fix or feature.
|
37
|
+
|
38
|
+
You may find using demo application useful for development and debugging.
|
39
|
+
|
40
|
+
- `cd demo`
|
41
|
+
- `rake db:schema:load`
|
42
|
+
- `rails s`
|
43
|
+
- Navigate to http://localhost:3000
|
44
|
+
|
45
|
+
### 5. Make a Pull Request
|
46
|
+
|
47
|
+
- If you never done it before read this: https://help.github.com/articles/about-pull-requests/
|
48
|
+
- When PR is submitted check if TravisCI ran all tests successfully didn't raise any issues
|
49
|
+
|
50
|
+
### 6. Done!
|
51
|
+
|
52
|
+
Somebody will shortly review your pull request and if everything is good will be
|
53
|
+
merged into master branch. Eventually gem will be published with your changes.
|
54
|
+
|
55
|
+
---
|
56
|
+
|
57
|
+
Thanks to all the great contributors over the years: https://github.com/bootstrap-ruby/bootstrap_form/graphs/contributors
|
data/Dangerfile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Adapted from https://github.com/ruby-grape/danger/blob/master/Dangerfile
|
2
|
+
# Q: What is a Dangerfile, anyway? A: See http://danger.systems/
|
3
|
+
|
4
|
+
# ------------------------------------------------------------------------------
|
5
|
+
# Additional pull request data
|
6
|
+
# ------------------------------------------------------------------------------
|
7
|
+
project_name = github.pr_json["base"]["repo"]["name"]
|
8
|
+
pr_number = github.pr_json["number"]
|
9
|
+
pr_url = github.pr_json["_links"]["html"]["href"]
|
10
|
+
|
11
|
+
# ------------------------------------------------------------------------------
|
12
|
+
# What changed?
|
13
|
+
# ------------------------------------------------------------------------------
|
14
|
+
has_lib_changes = !git.modified_files.grep(/^lib/).empty?
|
15
|
+
has_test_changes = !git.modified_files.grep(/^test/).empty?
|
16
|
+
has_changelog_changes = git.modified_files.include?("CHANGELOG.md")
|
17
|
+
|
18
|
+
# ------------------------------------------------------------------------------
|
19
|
+
# You've made changes to lib, but didn't write any tests?
|
20
|
+
# ------------------------------------------------------------------------------
|
21
|
+
if has_lib_changes && !has_test_changes
|
22
|
+
warn("There are code changes, but no corresponding tests. "\
|
23
|
+
"Please include tests if this PR introduces any modifications in "\
|
24
|
+
"#{project_name}'s behavior.",
|
25
|
+
:sticky => false)
|
26
|
+
end
|
27
|
+
|
28
|
+
# ------------------------------------------------------------------------------
|
29
|
+
# Have you updated CHANGELOG.md?
|
30
|
+
# ------------------------------------------------------------------------------
|
31
|
+
if !has_changelog_changes && has_lib_changes
|
32
|
+
markdown <<-MARKDOWN
|
33
|
+
Here's an example of a CHANGELOG.md entry (place it immediately under the `* Your contribution here!` line):
|
34
|
+
|
35
|
+
```markdown
|
36
|
+
* [##{pr_number}](#{pr_url}): #{github.pr_title} - [@#{github.pr_author}](https://github.com/#{github.pr_author}).
|
37
|
+
```
|
38
|
+
MARKDOWN
|
39
|
+
warn("Please update CHANGELOG.md with a description of your changes. "\
|
40
|
+
"If this PR is not a user-facing change (e.g. just refactoring), "\
|
41
|
+
"you can disregard this.", :sticky => false)
|
42
|
+
end
|
43
|
+
|
44
|
+
# ------------------------------------------------------------------------------
|
45
|
+
# Did you remove the CHANGELOG's "Your contribution here!" line?
|
46
|
+
# ------------------------------------------------------------------------------
|
47
|
+
if has_changelog_changes
|
48
|
+
if IO.read("CHANGELOG.md").scan(/^\s*[-\*] Your contribution here/i).count < 3
|
49
|
+
fail(
|
50
|
+
"Please put the `- Your contribution here!` line back into CHANGELOG.md.",
|
51
|
+
:sticky => false
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
data/Gemfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
# Uncomment and change rails version for testing purposes
|
6
|
+
# gem "rails", "~> 5.2.0.beta2"
|
7
|
+
|
8
|
+
group :development do
|
9
|
+
gem "htmlbeautifier"
|
10
|
+
end
|
11
|
+
|
12
|
+
group :test do
|
13
|
+
# can relax version requirement for Rails 5.2.beta3+
|
14
|
+
gem "minitest", "~> 5.10.3"
|
15
|
+
|
16
|
+
gem "diffy"
|
17
|
+
gem "equivalent-xml"
|
18
|
+
gem "mocha"
|
19
|
+
gem "sqlite3"
|
20
|
+
gem "timecop", "~> 0.7.1"
|
21
|
+
end
|
data/{MIT-LICENSE → LICENSE.txt}
RENAMED
data/README.md
CHANGED
@@ -1,22 +1,28 @@
|
|
1
|
-
[
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/bootstrap_form.svg)](http://badge.fury.io/rb/bootstrap_form)
|
1
|
+
⚠️ **This documentation is for the master branch, which is not yet stable and targets Bootstrap v4.** If you are using Bootstrap v3, refer to the stable [legacy-2.7](https://github.com/bootstrap-ruby/bootstrap_form/tree/legacy-2.7) branch.
|
3
2
|
|
4
|
-
|
3
|
+
---
|
5
4
|
|
6
|
-
|
7
|
-
|
5
|
+
# bootstrap_form
|
6
|
+
|
7
|
+
[![Build Status](https://travis-ci.org/bootstrap-ruby/bootstrap_form.svg?branch=master)](https://travis-ci.org/bootstrap-ruby/bootstrap_form)
|
8
|
+
[![Gem Version](https://badge.fury.io/rb/bootstrap_form.svg)](https://rubygems.org/gems/bootstrap_form)
|
9
|
+
|
10
|
+
**bootstrap_form** is a Rails form builder that makes it super easy to integrate
|
11
|
+
Bootstrap v4-style forms into your Rails application.
|
8
12
|
|
9
13
|
## Requirements
|
10
14
|
|
11
|
-
* Ruby
|
12
|
-
* Rails
|
13
|
-
*
|
15
|
+
* Ruby 2.2.2+
|
16
|
+
* Rails 5.0+ (Rails 5.1+ for `bootstrap_form_with`)
|
17
|
+
* Bootstrap 4.0.0+
|
14
18
|
|
15
19
|
## Installation
|
16
20
|
|
17
21
|
Add it to your Gemfile:
|
18
22
|
|
19
|
-
|
23
|
+
```ruby
|
24
|
+
gem "bootstrap_form", ">= 4.0.0.alpha1"
|
25
|
+
```
|
20
26
|
|
21
27
|
Then:
|
22
28
|
|
@@ -55,21 +61,15 @@ This generates the following HTML:
|
|
55
61
|
<label for="user_password">Password</label>
|
56
62
|
<input class="form-control" id="user_password" name="user[password]" type="password">
|
57
63
|
</div>
|
58
|
-
<div class="
|
59
|
-
<
|
60
|
-
|
61
|
-
|
62
|
-
</label>
|
64
|
+
<div class="form-check">
|
65
|
+
<input name="user[remember_me]" type="hidden" value="0">
|
66
|
+
<input class="form-check-input" id="user_remember_me" name="user[remember_me]" type="checkbox" value="1">
|
67
|
+
<label class="form-check-label" for="user_remember_me">Remember me</label>
|
63
68
|
</div>
|
64
|
-
<input class="btn btn-
|
69
|
+
<input class="btn btn-secondary" name="commit" type="submit" value="Log In">
|
65
70
|
</form>
|
66
71
|
```
|
67
72
|
|
68
|
-
### Nested Forms
|
69
|
-
|
70
|
-
In order to active [nested_form](https://github.com/ryanb/nested_form) support,
|
71
|
-
use `bootstrap_nested_form_for` instead of `bootstrap_form_for`.
|
72
|
-
|
73
73
|
### bootstrap_form_tag
|
74
74
|
|
75
75
|
If your form is not backed by a model, use the `bootstrap_form_tag`. Usage of this helper is the same as `bootstrap_form_for`, except no model object is passed in as the first argument. Here's an example:
|
@@ -81,6 +81,53 @@ If your form is not backed by a model, use the `bootstrap_form_tag`. Usage of th
|
|
81
81
|
<% end %>
|
82
82
|
```
|
83
83
|
|
84
|
+
### `bootstrap_form_with` (Rails 5.1+)
|
85
|
+
|
86
|
+
Note that `form_with` in Rails 5.1 does not add IDs to form elements and labels by default, which are both important to Bootstrap markup. This behavior is corrected in Rails 5.2.
|
87
|
+
|
88
|
+
To get started, just use the `bootstrap_form_with` helper in place of `form_with`. Here's an example:
|
89
|
+
|
90
|
+
```erb
|
91
|
+
<%= bootstrap_form_with(model: @user, local: true) do |f| %>
|
92
|
+
<%= f.email_field :email %>
|
93
|
+
<%= f.password_field :password %>
|
94
|
+
<%= f.check_box :remember_me %>
|
95
|
+
<%= f.submit "Log In" %>
|
96
|
+
<% end %>
|
97
|
+
```
|
98
|
+
|
99
|
+
This generates:
|
100
|
+
|
101
|
+
```html
|
102
|
+
<form role="form" action="/users" accept-charset="UTF-8" method="post">
|
103
|
+
<input name="utf8" type="hidden" value="✓" />
|
104
|
+
<div class="form-group">
|
105
|
+
<label class="required" for="user_email">Email</label>
|
106
|
+
<input class="form-control" type="email" value="steve@example.com" name="user[email]" />
|
107
|
+
</div>
|
108
|
+
<div class="form-group">
|
109
|
+
<label for="user_password">Password</label>
|
110
|
+
<input class="form-control" type="password" name="user[password]" />
|
111
|
+
<small class="form-text text-muted">A good password should be at least six characters long</small>
|
112
|
+
</div>
|
113
|
+
<div class="form-check">
|
114
|
+
<input name="user[remember_me]" type="hidden" value="0">
|
115
|
+
<input class="form-check-input" id="user_remember_me" name="user[remember_me]" type="checkbox" value="1">
|
116
|
+
<label class="form-check-label" for="user_remember_me">Remember me</label>
|
117
|
+
</div>
|
118
|
+
<input type="submit" name="commit" value="Log In" class="btn btn-secondary" data-disable-with="Log In" />
|
119
|
+
</form>
|
120
|
+
```
|
121
|
+
|
122
|
+
`bootstrap_form_with` supports both the `model:` and `url:` use cases
|
123
|
+
in `form_with`.
|
124
|
+
|
125
|
+
`form_with` has some important differences compared to `form_for` and `form_tag`, and these differences apply to `bootstrap_form_with`. A good summary of the differences can be found at: https://m.patrikonrails.com/rails-5-1s-form-with-vs-old-form-helpers-3a5f72a8c78a, or in the [Rails documentation](api.rubyonrails.org).
|
126
|
+
|
127
|
+
### Future Compatibility
|
128
|
+
|
129
|
+
The Rails team has [suggested](https://github.com/rails/rails/issues/25197) that `form_for` and `form_tag` may be deprecated and then removed in future versions of Rails. `bootstrap_form` will continue to support `bootstrap_form_for` and `bootstrap_form_tag` as long as Rails supports `form_for` and `form_tag`.
|
130
|
+
|
84
131
|
## Form Helpers
|
85
132
|
|
86
133
|
This gem wraps the following Rails form helpers:
|
@@ -115,6 +162,8 @@ This gem wraps the following Rails form helpers:
|
|
115
162
|
* time_zone_select
|
116
163
|
* url_field
|
117
164
|
* week_field
|
165
|
+
* submit
|
166
|
+
* button
|
118
167
|
|
119
168
|
These helpers accept the same options as the standard Rails form helpers, with
|
120
169
|
a few extra options:
|
@@ -140,6 +189,12 @@ To add custom classes to the field's label:
|
|
140
189
|
<%= f.text_field :email, label_class: "custom-class" %>
|
141
190
|
```
|
142
191
|
|
192
|
+
Or you can add the label as input placeholder instead (this automatically hides the label):
|
193
|
+
|
194
|
+
```erb
|
195
|
+
<%= f.text_field :email, label_as_placeholder: true %>
|
196
|
+
```
|
197
|
+
|
143
198
|
#### Required Fields
|
144
199
|
|
145
200
|
A label that is associated with a required field is automatically annotated with
|
@@ -166,7 +221,7 @@ In cases where this behavior is undesirable, use the `skip_required` option:
|
|
166
221
|
|
167
222
|
### Input Elements / Controls
|
168
223
|
|
169
|
-
To specify the class of the generated input, use the `control_class` option:
|
224
|
+
To specify the class of the generated input tag, use the `control_class` option:
|
170
225
|
|
171
226
|
```erb
|
172
227
|
<%= f.text_field :email, control_class: "custom-class" %>
|
@@ -190,31 +245,22 @@ en:
|
|
190
245
|
password: "A good password should be at least six characters long"
|
191
246
|
```
|
192
247
|
|
248
|
+
Help translations containing HTML should follow the convention of appending `_html` to the name:
|
249
|
+
|
250
|
+
```yml
|
251
|
+
en:
|
252
|
+
activerecord:
|
253
|
+
help:
|
254
|
+
user:
|
255
|
+
password_html: "A <strong>good</strong> password should be at least six characters long"
|
256
|
+
```
|
257
|
+
|
193
258
|
If your model name has multiple words (like `SuperUser`), the key on the
|
194
259
|
translation file should be underscored (`super_user`).
|
195
260
|
|
196
261
|
You can override help translations for a particular field by passing the `help`
|
197
262
|
option or turn them off completely by passing `help: false`.
|
198
263
|
|
199
|
-
### Icons
|
200
|
-
|
201
|
-
To add an icon to a field, use the `icon` option and pass the icon name
|
202
|
-
*without* the 'glyphicon' prefix:
|
203
|
-
|
204
|
-
```erb
|
205
|
-
<%= f.text_field :login, icon: "user" %>
|
206
|
-
```
|
207
|
-
|
208
|
-
This automatically adds the `has-feedback` class to the `form-group`:
|
209
|
-
|
210
|
-
```html
|
211
|
-
<div class="form-group has-feedback">
|
212
|
-
<label class="control-label" for="user_login">Login</label>
|
213
|
-
<input class="form-control" id="user_login" name="user[login]" type="text" />
|
214
|
-
<span class="glyphicon glyphicon-user form-control-feedback"></span>
|
215
|
-
</div>
|
216
|
-
```
|
217
|
-
|
218
264
|
### Prepending and Appending Inputs
|
219
265
|
|
220
266
|
You can pass `prepend` and/or `append` options to input fields:
|
@@ -227,10 +273,10 @@ You can also prepend and append buttons. Note: The buttons must contain the
|
|
227
273
|
`btn` class to generate the correct markup.
|
228
274
|
|
229
275
|
```erb
|
230
|
-
<%= f.text_field :search, append: link_to("Go", "#", class: "btn btn-
|
276
|
+
<%= f.text_field :search, append: link_to("Go", "#", class: "btn btn-secondary") %>
|
231
277
|
```
|
232
278
|
|
233
|
-
To add a class to the input group wrapper, use `:input_group_class` option.
|
279
|
+
To add a class to the input group wrapper, use the `:input_group_class` option.
|
234
280
|
|
235
281
|
```erb
|
236
282
|
<%= f.email_field :email, append: f.primary('Subscribe'), input_group_class: 'input-group-lg' %>
|
@@ -249,7 +295,7 @@ Which produces the following output:
|
|
249
295
|
|
250
296
|
```erb
|
251
297
|
<div class="form-group has-warning" data-foo="bar">
|
252
|
-
<label class="control-label" for="user_name">Id</label>
|
298
|
+
<label class="form-control-label" for="user_name">Id</label>
|
253
299
|
<input class="form-control" id="user_name" name="user[name]" type="text">
|
254
300
|
</div>
|
255
301
|
```
|
@@ -261,7 +307,7 @@ You still can use `wrapper_class` option to set only a css class. This is just a
|
|
261
307
|
Our select helper accepts the same arguments as the [default Rails helper](http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-select). Here's an example of how you pass both options and html_options hashes:
|
262
308
|
|
263
309
|
```erb
|
264
|
-
<%= f.select :product, [[
|
310
|
+
<%= f.select :product, [["Apple", 1], ["Grape", 2]], { label: "Choose your favorite fruit:" }, { class: "selectpicker", wrapper: { class: 'has-warning', data: { foo: 'bar' } } } %>
|
265
311
|
```
|
266
312
|
|
267
313
|
### Checkboxes and Radios
|
@@ -304,7 +350,7 @@ To display checkboxes and radios inline, pass the `inline: true` option:
|
|
304
350
|
|
305
351
|
#### Collections
|
306
352
|
|
307
|
-
|
353
|
+
`bootstrap_form` also provides helpers that automatically creates the
|
308
354
|
`form_group` and the `radio_button`s or `check_box`es for you:
|
309
355
|
|
310
356
|
```erb
|
@@ -326,13 +372,13 @@ You can create a static control like this:
|
|
326
372
|
<%= f.static_control :email %>
|
327
373
|
```
|
328
374
|
|
329
|
-
Here's the output:
|
375
|
+
Here's the output for a horizontal layout:
|
330
376
|
|
331
377
|
```html
|
332
378
|
<div class="form-group">
|
333
|
-
<label class="col-sm-2 control-label" for="user_email">Email</label>
|
379
|
+
<label class="col-sm-2 form-control-label" for="user_email">Email</label>
|
334
380
|
<div class="col-sm-10">
|
335
|
-
<
|
381
|
+
<input class="form-control-plaintext" id="user_email" name="user[email]" readonly="readonly" type="text" value="test@email.com"/>
|
336
382
|
</div>
|
337
383
|
</div>
|
338
384
|
```
|
@@ -350,12 +396,12 @@ You can also create a static control that isn't based on a model attribute:
|
|
350
396
|
The multiple selects that the date and time helpers (`date_select`,
|
351
397
|
`time_select`, `datetime_select`) generate are wrapped inside a
|
352
398
|
`div.rails-bootstrap-forms-[date|time|datetime]-select` tag. This is because
|
353
|
-
Bootstrap automatically
|
399
|
+
Bootstrap automatically styles our controls as `block`s. This wrapper fixes
|
354
400
|
this defining these selects as `inline-block` and a width of `auto`.
|
355
401
|
|
356
402
|
### Submit Buttons
|
357
403
|
|
358
|
-
The `btn btn-
|
404
|
+
The `btn btn-secondary` css classes are automatically added to your submit
|
359
405
|
buttons.
|
360
406
|
|
361
407
|
```erb
|
@@ -375,6 +421,26 @@ You can specify your own classes like this:
|
|
375
421
|
<%= f.submit "Log In", class: "btn btn-success" %>
|
376
422
|
```
|
377
423
|
|
424
|
+
If the `primary` helper receives a `render_as_button: true` option or a block,
|
425
|
+
it will be rendered as an HTML button, instead of an input tag. This allows you
|
426
|
+
to specify HTML content and styling for your buttons (such as adding
|
427
|
+
illustrative icons to them). For example, the following statements
|
428
|
+
|
429
|
+
```erb
|
430
|
+
<%= f.primary "Save changes <span class='fa fa-save'></span>".html_safe, render_as_button: true %>
|
431
|
+
|
432
|
+
<%= f.primary do
|
433
|
+
concat 'Save changes '
|
434
|
+
concat content_tag(:span, nil, class: 'fa fa-save')
|
435
|
+
end %>
|
436
|
+
```
|
437
|
+
|
438
|
+
are equivalent, and each of them both be rendered as
|
439
|
+
|
440
|
+
```html
|
441
|
+
<button name="button" type="submit" class="btn btn-primary">Save changes <span class="fa fa-save"></span></button>
|
442
|
+
```
|
443
|
+
|
378
444
|
### Accessing Rails Form Helpers
|
379
445
|
|
380
446
|
If you want to use the original Rails form helpers for a particular field,
|
@@ -446,7 +512,7 @@ The `label_col` and `control_col` css classes can also be changed per control:
|
|
446
512
|
|
447
513
|
### Custom Field Layout
|
448
514
|
|
449
|
-
The `layout` can be overridden per field
|
515
|
+
The form-level `layout` can be overridden per field, unless the form-level layout was `inline`:
|
450
516
|
|
451
517
|
```erb
|
452
518
|
<%= bootstrap_form_for(@user, layout: :horizontal) do |f| %>
|
@@ -459,19 +525,34 @@ The `layout` can be overridden per field:
|
|
459
525
|
<% end %>
|
460
526
|
```
|
461
527
|
|
462
|
-
|
528
|
+
A form-level `layout: :inline` can't be overridden because of the way Bootstrap 4 implements in-line layouts. One possible work-around is to leave the form-level layout as default, and specify the individual fields as `layout: :inline`, except for the fields(s) that should be other than in-line.
|
529
|
+
|
530
|
+
### Custom Form Element Styles
|
531
|
+
|
532
|
+
The `custom` option can be used to replace the browser default styles for check boxes and radio buttons with dedicated Bootstrap styled form elements. Here's an example:
|
533
|
+
|
534
|
+
```erb
|
535
|
+
<%= bootstrap_form_for(@user) do |f| %>
|
536
|
+
<%= f.email_field :email %>
|
537
|
+
<%= f.password_field :password %>
|
538
|
+
<%= f.check_box :remember_me, custom: true %>
|
539
|
+
<%= f.submit "Log In" %>
|
540
|
+
<% end %>
|
541
|
+
```
|
542
|
+
|
543
|
+
## Validation and Errors
|
463
544
|
|
464
545
|
### Inline Errors
|
465
546
|
|
466
|
-
By default, fields that have validation errors will outlined in red and the
|
547
|
+
By default, fields that have validation errors will be outlined in red and the
|
467
548
|
error will be displayed below the field. Rails normally wraps the fields in a
|
468
549
|
div (field_with_errors), but this behavior is suppressed. Here's an example:
|
469
550
|
|
470
551
|
```html
|
471
|
-
<div class="form-group
|
472
|
-
<label class="control-label" for="user_email">Email</label>
|
473
|
-
<input class="form-control" id="user_email" name="user[email]" type="email" value="">
|
474
|
-
<
|
552
|
+
<div class="form-group">
|
553
|
+
<label class="form-control-label" for="user_email">Email</label>
|
554
|
+
<input class="form-control is-invalid" id="user_email" name="user[email]" type="email" value="">
|
555
|
+
<small class="invalid-feedback">can't be blank</small>
|
475
556
|
</div>
|
476
557
|
```
|
477
558
|
|
@@ -576,46 +657,32 @@ Which outputs:
|
|
576
657
|
bootstrap_form follows standard rails conventions so it's i18n-ready. See more
|
577
658
|
here: http://guides.rubyonrails.org/i18n.html#translations-for-active-record-models
|
578
659
|
|
579
|
-
##
|
580
|
-
|
581
|
-
http://www.codetriage.com/potenza/bootstrap_form
|
582
|
-
|
583
|
-
## Contributing
|
584
|
-
|
585
|
-
We love pull requests! Here's a quick guide for contributing:
|
586
|
-
|
587
|
-
1. Fork the repo.
|
660
|
+
## Other Tips and Edge Cases
|
661
|
+
By their very nature, forms are extremely diverse. It would be extremely difficult to provide a gem that could handle every need. Here are some tips for handling edge cases.
|
588
662
|
|
589
|
-
|
663
|
+
### Empty But Visible Labels
|
664
|
+
Some third party plug-ins require an empty but visible label on an input control. The `hide_label` option generates a label that won't appear on the screen, but it's considered invisible and therefore doesn't work with such a plug-in. An empty label (e.g. `""`) causes the underlying Rails helper to generate a label based on the field's attribute's name.
|
590
665
|
|
666
|
+
The solution is to use a zero-width character for the label, or some other "empty" HTML. For example:
|
591
667
|
```
|
592
|
-
|
593
|
-
bundle exec appraisal install
|
668
|
+
label: "​".html_safe
|
594
669
|
```
|
595
|
-
|
596
|
-
3. Run the existing test suite:
|
597
|
-
|
670
|
+
or
|
598
671
|
```
|
599
|
-
|
600
|
-
$ bundle exec appraisal rake test
|
672
|
+
label: "<span></span>".html_safe
|
601
673
|
```
|
602
674
|
|
603
|
-
|
604
|
-
|
605
|
-
5. Add your changes and make your test(s) pass. Following the conventions you
|
606
|
-
see used in the source will increase the chance that your pull request is
|
607
|
-
accepted right away.
|
608
|
-
|
609
|
-
6. Update the README if necessary.
|
610
|
-
|
611
|
-
7. Add a line to the CHANGELOG for your bug fix or feature.
|
675
|
+
## Code Triage page
|
612
676
|
|
613
|
-
|
677
|
+
http://www.codetriage.com/potenza/bootstrap_form
|
614
678
|
|
615
|
-
##
|
679
|
+
## Contributing
|
616
680
|
|
617
|
-
|
681
|
+
We welcome contributions.
|
682
|
+
If you're considering contributing to bootstrap_form,
|
683
|
+
please review the [Contributing](/CONTRIBUTING.md)
|
684
|
+
document first.
|
618
685
|
|
619
686
|
## License
|
620
687
|
|
621
|
-
MIT License. Copyright 2012-
|
688
|
+
MIT License. Copyright 2012-2018 Stephen Potenza (https://github.com/potenza)
|