simple_form 5.0.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +49 -8
- data/MIT-LICENSE +2 -1
- data/README.md +96 -51
- data/lib/generators/simple_form/install_generator.rb +2 -2
- data/lib/generators/simple_form/templates/README +2 -3
- data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +2 -2
- data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +127 -195
- data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +1 -1
- data/lib/simple_form/components/label_input.rb +1 -1
- data/lib/simple_form/components/labels.rb +3 -5
- data/lib/simple_form/components/maxlength.rb +0 -4
- data/lib/simple_form/components/minlength.rb +0 -4
- data/lib/simple_form/form_builder.rb +7 -10
- data/lib/simple_form/inputs/base.rb +0 -3
- data/lib/simple_form/inputs/boolean_input.rb +6 -2
- data/lib/simple_form/inputs/collection_check_boxes_input.rb +1 -1
- data/lib/simple_form/inputs/collection_input.rb +3 -5
- data/lib/simple_form/inputs/grouped_collection_select_input.rb +1 -1
- data/lib/simple_form/inputs/priority_input.rb +16 -2
- data/lib/simple_form/inputs/rich_text_area_input.rb +12 -0
- data/lib/simple_form/inputs.rb +1 -0
- data/lib/simple_form/railtie.rb +4 -0
- data/lib/simple_form/version.rb +1 -1
- data/lib/simple_form/wrappers/leaf.rb +1 -1
- data/lib/simple_form/wrappers/root.rb +8 -3
- data/lib/simple_form.rb +10 -6
- metadata +22 -93
- data/lib/simple_form/i18n_cache.rb +0 -23
- data/test/action_view_extensions/builder_test.rb +0 -634
- data/test/action_view_extensions/form_helper_test.rb +0 -172
- data/test/components/custom_components_test.rb +0 -62
- data/test/components/label_test.rb +0 -356
- data/test/form_builder/association_test.rb +0 -252
- data/test/form_builder/button_test.rb +0 -48
- data/test/form_builder/error_notification_test.rb +0 -80
- data/test/form_builder/error_test.rb +0 -281
- data/test/form_builder/general_test.rb +0 -534
- data/test/form_builder/hint_test.rb +0 -150
- data/test/form_builder/input_field_test.rb +0 -195
- data/test/form_builder/label_test.rb +0 -136
- data/test/form_builder/wrapper_test.rb +0 -371
- data/test/generators/simple_form_generator_test.rb +0 -43
- data/test/inputs/boolean_input_test.rb +0 -243
- data/test/inputs/collection_check_boxes_input_test.rb +0 -327
- data/test/inputs/collection_radio_buttons_input_test.rb +0 -450
- data/test/inputs/collection_select_input_test.rb +0 -378
- data/test/inputs/color_input_test.rb +0 -10
- data/test/inputs/datetime_input_test.rb +0 -176
- data/test/inputs/disabled_test.rb +0 -92
- data/test/inputs/discovery_test.rb +0 -142
- data/test/inputs/file_input_test.rb +0 -17
- data/test/inputs/general_test.rb +0 -133
- data/test/inputs/grouped_collection_select_input_test.rb +0 -183
- data/test/inputs/hidden_input_test.rb +0 -32
- data/test/inputs/numeric_input_test.rb +0 -177
- data/test/inputs/priority_input_test.rb +0 -50
- data/test/inputs/readonly_test.rb +0 -102
- data/test/inputs/required_test.rb +0 -158
- data/test/inputs/string_input_test.rb +0 -158
- data/test/inputs/text_input_test.rb +0 -37
- data/test/simple_form_test.rb +0 -18
- data/test/support/discovery_inputs.rb +0 -65
- data/test/support/misc_helpers.rb +0 -274
- data/test/support/mock_controller.rb +0 -30
- data/test/support/models.rb +0 -353
- data/test/test_helper.rb +0 -95
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3b89606503cd2fc01363418e51dd00630a770820b8482f35aa85ddba1a653cc5
|
|
4
|
+
data.tar.gz: 1a078f896c0e4bd41b0462a5b591fcc04038dbb0dd64c65c61b5584450a9b569
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 17a0ecd1d326536cdb1e4e1291bcfbad43fac2d8e4e0895ad0619515e9f951c4618da9b4ad8c568bcd9b702f94227f58b3967a14eb9b7adc3343ca07cfb8f451
|
|
7
|
+
data.tar.gz: 810793e24f74792775bbe3e5bba0b157f59673879b8c6c360c4af15ba2d91fc0d293eace5556aba5b32e7a99f01d7e3e96099046401e802fbba3a1b2bcddcaf5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,45 @@
|
|
|
1
|
-
##
|
|
1
|
+
## 5.3.0
|
|
2
|
+
|
|
3
|
+
* Add support for Rails 7.1. (no meaningful changes required.)
|
|
4
|
+
* Add `SimpleForm.deprecator` to integrate with new application deprecators in Rails 7.1.
|
|
5
|
+
* Remove test files from the gem package. [@orien](https://github.com/orien)
|
|
6
|
+
* Speed up input mapping lookup by avoiding rescuing exceptions. [@meanphil](https://github.com/meanphil) [@kriom](https://github.com/kriom) [@egeek](https://github.com/egeek)
|
|
7
|
+
|
|
8
|
+
## 5.2.0
|
|
9
|
+
|
|
10
|
+
* Add support for Rails 7.0 and Ruby 3.1/3.2 (no changes required)
|
|
11
|
+
* Fix escaping issue on boolean input with `include_hidden: false` and custom wrapper.
|
|
12
|
+
* Update Bootstrap install generator version 5. [@mhw](https://github.com/mhw)
|
|
13
|
+
* Accept proc as `group_method` for grouped collection select
|
|
14
|
+
* Honor `include_hidden` option on inline boolean inputs [@yboulkaid](https://github.com/yboulkaid)
|
|
15
|
+
* Fix deprecation error when using country_select input.
|
|
16
|
+
|
|
17
|
+
## 5.1.0
|
|
18
|
+
|
|
19
|
+
* Remove `I18nCache` module entirely. It was added complexity for very little gain in some translations, and caused extra trouble upgrading to Ruby 3. If you need that level of caching consider looking into I18n caching as a whole.
|
|
20
|
+
* Add support for Ruby 3.0, drop support for Ruby < 2.5.
|
|
21
|
+
* Add support for Rails 6.1, drop support for Rails < 5.2.
|
|
22
|
+
* Move CI to GitHub Actions.
|
|
23
|
+
|
|
24
|
+
## 5.0.3
|
|
25
|
+
|
|
26
|
+
### Bug fix
|
|
27
|
+
* Fix for ActiveStorage::Attached::Many. [@enriquez](https://github.com/enriquez)
|
|
28
|
+
|
|
29
|
+
## 5.0.2
|
|
30
|
+
|
|
31
|
+
### Enhancements
|
|
32
|
+
* Remove instruction to use form-inline class. [@goalaleo](https://github.com/goalaleo)
|
|
33
|
+
* Added RichTextAreaInput for ActionText. [itsterry](https://github.com/itsterry)
|
|
34
|
+
* Skip valid_class check if no class defined. [TALlama](https://github.com/TALlama)
|
|
35
|
+
|
|
36
|
+
### Bug fix
|
|
37
|
+
* Fix 'aria-required' field generated by prompt. [@CarlosAlbertoSantos](https://github.com/CarlosAlbertoSantos)
|
|
38
|
+
|
|
39
|
+
## 5.0.1
|
|
40
|
+
|
|
41
|
+
### Bug fix
|
|
42
|
+
* Replace `_url` with `remote_url` when trying to guess file inputs [@tegon](https://github.com/tegon). This has the side-effect of changing carrierwave's support from `0.2.1` to `0.2.2`.
|
|
2
43
|
|
|
3
44
|
## 5.0.0
|
|
4
45
|
|
|
@@ -107,7 +148,7 @@ See http://blog.plataformatec.com.br/2019/09/incorrect-access-control-in-simple-
|
|
|
107
148
|
|
|
108
149
|
### bug fix
|
|
109
150
|
* Fix `merge_wrapper_options` to correctly merge options with duplicated keys. [@herminiotorres](https://github.com/herminiotorres)
|
|
110
|
-
Closes [#1278](https://github.com/
|
|
151
|
+
Closes [#1278](https://github.com/heartcombo/simple_form/issues/1278).
|
|
111
152
|
|
|
112
153
|
## 3.2.1
|
|
113
154
|
|
|
@@ -169,11 +210,11 @@ See http://blog.plataformatec.com.br/2019/09/incorrect-access-control-in-simple-
|
|
|
169
210
|
* Add `boolean_label_class` config.
|
|
170
211
|
* Add `:html` option to include additional attributes on custom wrappers [@remofritzsche](https://github.com/remofritzsche) and [@ulissesalmeida](https://github.com/ulissesalmeida)
|
|
171
212
|
* Make possible to use the Wrappers API to define attributes for the components.
|
|
172
|
-
See https://github.com/
|
|
213
|
+
See https://github.com/heartcombo/simple_form/pull/997 for more information.
|
|
173
214
|
* Put a whitespace before the `inline_label` options of boolean input if it is present.
|
|
174
215
|
* Add support to configure the `label_text` proc at the wrapper level. [@NOX73](https://github.com/NOX73)
|
|
175
216
|
* `label_text` proc now receive three arguments (label, request, and if the label was explicit). [@timscott](https://github.com/timscott)
|
|
176
|
-
* Add I18n support to `:include_blank` and `:prompt` when `:translate` is used as value. [@haines](https://github.com/
|
|
217
|
+
* Add I18n support to `:include_blank` and `:prompt` when `:translate` is used as value. [@haines](https://github.com/heartcombo/simple_form/pull/616)
|
|
177
218
|
* Add support to define custom error messages for the attributes.
|
|
178
219
|
* Add support to change the I18n scope to be used in Simple Form. [@nielsbuus](https://github.com/nielsbuus)
|
|
179
220
|
* The default form class can now be overridden with `html: { :class }`. [@rmm5t](https://github.com/rmm5t)
|
|
@@ -182,16 +223,16 @@ See http://blog.plataformatec.com.br/2019/09/incorrect-access-control-in-simple-
|
|
|
182
223
|
* Fix `full_error` when the attribute is an association. [@mvdamme](https://github.com/jorge-d)
|
|
183
224
|
* Fix suppport to `:namespace` and `:index` options for nested check boxes and radio buttons when the attribute is an association.
|
|
184
225
|
* Collection input that uses automatic collection translation properly sets checked values.
|
|
185
|
-
Closes [#971](https://github.com/
|
|
226
|
+
Closes [#971](https://github.com/heartcombo/simple_form/issues/971) [@nashby](https://github.com/nashby)
|
|
186
227
|
* Collection input generates `required` attribute if it has `prompt` option. [@nashby](https://github.com/nashby)
|
|
187
228
|
* Grouped collection uses the first non-empty object to detect label and value methods.
|
|
188
229
|
|
|
189
230
|
## deprecation
|
|
190
231
|
* Methods on custom inputs now accept a required argument with the wrapper options.
|
|
191
|
-
See https://github.com/
|
|
232
|
+
See https://github.com/heartcombo/simple_form/pull/997 for more information.
|
|
192
233
|
* SimpleForm.form_class is deprecated in favor of SimpleForm.default_form_class.
|
|
193
234
|
Future versions of Simple Form will not generate `simple_form` class for the form
|
|
194
235
|
element.
|
|
195
|
-
See https://github.com/
|
|
236
|
+
See https://github.com/heartcombo/simple_form/pull/1109 for more information.
|
|
196
237
|
|
|
197
|
-
Please check [v3.0](https://github.com/
|
|
238
|
+
Please check [v3.0](https://github.com/heartcombo/simple_form/blob/v3.0/CHANGELOG.md) for previous changes.
|
data/MIT-LICENSE
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
Copyright (c)
|
|
1
|
+
Copyright (c) 2020-2023 Rafael França, Carlos Antônio da Silva
|
|
2
|
+
Copyright (c) 2009-2019 Plataformatec
|
|
2
3
|
|
|
3
4
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
5
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
.
|
|
1
|
+

|
|
4
2
|
|
|
5
3
|
Rails forms made easy.
|
|
6
4
|
|
|
@@ -9,8 +7,44 @@ your forms. The basic goal of **Simple Form** is to not touch your way of defini
|
|
|
9
7
|
you find the better design for your eyes. Most of the DSL was inherited from Formtastic,
|
|
10
8
|
which we are thankful for and should make you feel right at home.
|
|
11
9
|
|
|
12
|
-
INFO: This README
|
|
13
|
-
|
|
10
|
+
INFO: This README refers to **Simple Form** 5.0. For older releases, check the related branch for your version.
|
|
11
|
+
|
|
12
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
13
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Installation](#installation)
|
|
17
|
+
- [Bootstrap](#bootstrap-5)
|
|
18
|
+
- [Zurb Foundation 5](#zurb-foundation-5)
|
|
19
|
+
- [Country Select](#country-select)
|
|
20
|
+
- [Usage](#usage)
|
|
21
|
+
- [Stripping away all wrapper divs](#stripping-away-all-wrapper-divs)
|
|
22
|
+
- [Collections](#collections)
|
|
23
|
+
- [Priority](#priority)
|
|
24
|
+
- [Associations](#associations)
|
|
25
|
+
- [Buttons](#buttons)
|
|
26
|
+
- [Wrapping Rails Form Helpers](#wrapping-rails-form-helpers)
|
|
27
|
+
- [Extra helpers](#extra-helpers)
|
|
28
|
+
- [Simple Fields For](#simple-fields-for)
|
|
29
|
+
- [Collection Radio Buttons](#collection-radio-buttons)
|
|
30
|
+
- [Collection Check Boxes](#collection-check-boxes)
|
|
31
|
+
- [Available input types and defaults for each column type](#available-input-types-and-defaults-for-each-column-type)
|
|
32
|
+
- [Custom inputs](#custom-inputs)
|
|
33
|
+
- [Custom form builder](#custom-form-builder)
|
|
34
|
+
- [I18n](#i18n)
|
|
35
|
+
- [Configuration](#configuration)
|
|
36
|
+
- [The wrappers API](#the-wrappers-api)
|
|
37
|
+
- [Custom Components](#custom-components)
|
|
38
|
+
- [HTML 5 Notice](#html-5-notice)
|
|
39
|
+
- [Using non Active Record objects](#using-non-active-record-objects)
|
|
40
|
+
- [Information](#information)
|
|
41
|
+
- [RDocs](#rdocs)
|
|
42
|
+
- [Supported Ruby / Rails versions](#supported-ruby--rails-versions)
|
|
43
|
+
- [Bug reports](#bug-reports)
|
|
44
|
+
- [Maintainers](#maintainers)
|
|
45
|
+
- [License](#license)
|
|
46
|
+
|
|
47
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
14
48
|
|
|
15
49
|
## Installation
|
|
16
50
|
|
|
@@ -32,21 +66,23 @@ Run the generator:
|
|
|
32
66
|
rails generate simple_form:install
|
|
33
67
|
```
|
|
34
68
|
|
|
35
|
-
### Bootstrap
|
|
69
|
+
### Bootstrap 5
|
|
36
70
|
|
|
37
|
-
**Simple Form** can be easily integrated
|
|
38
|
-
|
|
71
|
+
**Simple Form** can be easily integrated with [Bootstrap 5](http://getbootstrap.com/).
|
|
72
|
+
Use the `bootstrap` option in the install generator, like this:
|
|
39
73
|
|
|
40
74
|
```console
|
|
41
75
|
rails generate simple_form:install --bootstrap
|
|
42
76
|
```
|
|
43
77
|
|
|
78
|
+
This will add an initializer that configures **Simple Form** wrappers for
|
|
79
|
+
Bootstrap 5's [form controls](https://getbootstrap.com/docs/5.0/forms/overview/).
|
|
44
80
|
You have to be sure that you added a copy of the [Bootstrap](http://getbootstrap.com/)
|
|
45
81
|
assets on your application.
|
|
46
82
|
|
|
47
83
|
For more information see the generator output, our
|
|
48
|
-
[example application code](https://github.com/
|
|
49
|
-
[the live example app](
|
|
84
|
+
[example application code](https://github.com/heartcombo/simple_form-bootstrap) and
|
|
85
|
+
[the live example app](https://simple-form-bootstrap.herokuapp.com/).
|
|
50
86
|
|
|
51
87
|
### Zurb Foundation 5
|
|
52
88
|
|
|
@@ -118,8 +154,8 @@ of any of them:
|
|
|
118
154
|
|
|
119
155
|
```erb
|
|
120
156
|
<%= simple_form_for @user do |f| %>
|
|
121
|
-
<%= f.input :username, label_html: { class: 'my_class' } %>
|
|
122
|
-
<%= f.input :password, hint: false, error_html: { id: 'password_error'} %>
|
|
157
|
+
<%= f.input :username, label_html: { class: 'my_class' }, hint_html: { class: 'hint_class' } %>
|
|
158
|
+
<%= f.input :password, hint: false, error_html: { id: 'password_error' } %>
|
|
123
159
|
<%= f.input :password_confirmation, label: false %>
|
|
124
160
|
<%= f.button :submit %>
|
|
125
161
|
<% end %>
|
|
@@ -184,7 +220,7 @@ By default, **Simple Form** will look at the column type in the database and use
|
|
|
184
220
|
appropriate input for the column. For example, a column created with type
|
|
185
221
|
`:text` in the database will use a `textarea` input by default. See the section
|
|
186
222
|
[Available input types and defaults for each column
|
|
187
|
-
type](https://github.com/
|
|
223
|
+
type](https://github.com/heartcombo/simple_form#available-input-types-and-defaults-for-each-column-type)
|
|
188
224
|
for a complete list of defaults.
|
|
189
225
|
|
|
190
226
|
**Simple Form** also lets you overwrite the default input type it creates:
|
|
@@ -221,7 +257,18 @@ the wrapper as well:
|
|
|
221
257
|
<%= f.input :date_of_birth, as: :date, start_year: Date.today.year - 90,
|
|
222
258
|
end_year: Date.today.year - 12, discard_day: true,
|
|
223
259
|
order: [:month, :year] %>
|
|
224
|
-
<%= f.input :accepts, as: :boolean, checked_value:
|
|
260
|
+
<%= f.input :accepts, as: :boolean, checked_value: 'positive', unchecked_value: 'negative' %>
|
|
261
|
+
<%= f.button :submit %>
|
|
262
|
+
<% end %>
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
By default, **Simple Form** generates a hidden field to handle the un-checked case for boolean fields.
|
|
266
|
+
Passing `unchecked_value: false` in the options for boolean fields will cause this hidden field to be omitted,
|
|
267
|
+
following the convention in Rails. You can also specify `include_hidden: false` to skip the hidden field:
|
|
268
|
+
|
|
269
|
+
```erb
|
|
270
|
+
<%= simple_form_for @user do |f| %>
|
|
271
|
+
<%= f.input :just_the_checked_case, as: :boolean, include_hidden: false %>
|
|
225
272
|
<%= f.button :submit %>
|
|
226
273
|
<% end %>
|
|
227
274
|
```
|
|
@@ -288,7 +335,7 @@ end
|
|
|
288
335
|
</form>
|
|
289
336
|
```
|
|
290
337
|
|
|
291
|
-
To view the actual RDocs for this, check them out here - http://rubydoc.info/github/
|
|
338
|
+
To view the actual RDocs for this, check them out here - http://rubydoc.info/github/heartcombo/simple_form/main/SimpleForm/FormBuilder:input_field
|
|
292
339
|
|
|
293
340
|
### Collections
|
|
294
341
|
|
|
@@ -318,7 +365,7 @@ Collection inputs accept two other options beside collections:
|
|
|
318
365
|
Those methods are useful to manipulate the given collection. Both of these options also accept
|
|
319
366
|
lambda/procs in case you want to calculate the value or label in a special way eg. custom
|
|
320
367
|
translation. You can also define a `to_label` method on your model as **Simple Form** will search for
|
|
321
|
-
and use `:to_label` as a `:label_method` first if it is found.
|
|
368
|
+
and use `:to_label` as a `:label_method` first if it is found.
|
|
322
369
|
|
|
323
370
|
By default, **Simple Form** will use the first item from an array as the label and the second one as the value.
|
|
324
371
|
If you want to change this behavior you must make it explicit, like this:
|
|
@@ -329,14 +376,13 @@ If you want to change this behavior you must make it explicit, like this:
|
|
|
329
376
|
<% end %>
|
|
330
377
|
```
|
|
331
378
|
|
|
332
|
-
All other options given are sent straight to the underlying helper. For example, you can
|
|
379
|
+
All other options given are sent straight to the underlying Rails helper(s): [`collection_select`](http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_select), [`collection_check_boxes`](http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_check_boxes), [`collection_radio_buttons`](http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_radio_buttons). For example, you can pass `prompt` and `selected` as:
|
|
333
380
|
|
|
334
381
|
```ruby
|
|
335
382
|
f.input :age, collection: 18..60, prompt: "Select your age", selected: 21
|
|
336
383
|
```
|
|
337
|
-
Extra options are passed into helper [`collection_select`](http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_select).
|
|
338
384
|
|
|
339
|
-
|
|
385
|
+
It may also be useful to explicitly pass a value to the optional `:selected` like above, especially if passing a collection of nested objects.
|
|
340
386
|
|
|
341
387
|
It is also possible to create grouped collection selects, that will use the html *optgroup* tags, like this:
|
|
342
388
|
|
|
@@ -541,7 +587,7 @@ end
|
|
|
541
587
|
To add a CSS class to the label item, you can use the `item_label_class` option:
|
|
542
588
|
|
|
543
589
|
```ruby
|
|
544
|
-
f.collection_check_boxes :role_ids, Role.all, :id, :name, item_label_class: 'my-custom-class'
|
|
590
|
+
f.collection_check_boxes :role_ids, Role.all, :id, :name, item_label_class: 'my-custom-class'
|
|
545
591
|
```
|
|
546
592
|
|
|
547
593
|
## Available input types and defaults for each column type
|
|
@@ -561,6 +607,7 @@ Mapping | Generated HTML Element | Database Column Type
|
|
|
561
607
|
`password` | `input[type=password]` | `string` with `name =~ /password/`
|
|
562
608
|
`search` | `input[type=search]` | -
|
|
563
609
|
`uuid` | `input[type=text]` | `uuid`
|
|
610
|
+
`color` | `input[type=color]` | `string`
|
|
564
611
|
`text` | `textarea` | `text`
|
|
565
612
|
`hstore` | `textarea` | `hstore`
|
|
566
613
|
`json` | `textarea` | `json`
|
|
@@ -991,7 +1038,7 @@ when the content is present.
|
|
|
991
1038
|
|
|
992
1039
|
## Custom Components
|
|
993
1040
|
|
|
994
|
-
When you use custom wrappers, you might also be looking for a way to add custom components to your
|
|
1041
|
+
When you use custom wrappers, you might also be looking for a way to add custom components to your
|
|
995
1042
|
wrapper. The default components are:
|
|
996
1043
|
|
|
997
1044
|
```ruby
|
|
@@ -1064,7 +1111,7 @@ Finally, add a new wrapper to the config/initializers/simple_form.rb file:
|
|
|
1064
1111
|
```ruby
|
|
1065
1112
|
config.wrappers :with_numbers, tag: 'div', class: 'row', error_class: 'error' do |b|
|
|
1066
1113
|
b.use :html5
|
|
1067
|
-
b.use :number, wrap_with: { tag: 'div', class: 'span1 number'}
|
|
1114
|
+
b.use :number, wrap_with: { tag: 'div', class: 'span1 number' }
|
|
1068
1115
|
b.wrapper tag: 'div', class: 'span8' do |ba|
|
|
1069
1116
|
ba.use :placeholder
|
|
1070
1117
|
ba.use :label
|
|
@@ -1142,7 +1189,7 @@ by passing the html5 option:
|
|
|
1142
1189
|
|
|
1143
1190
|
### Using non Active Record objects
|
|
1144
1191
|
|
|
1145
|
-
There are few ways to build forms with objects that don't inherit from Active Record, as
|
|
1192
|
+
There are few ways to build forms with objects that don't inherit from Active Record, as
|
|
1146
1193
|
follows:
|
|
1147
1194
|
|
|
1148
1195
|
You can include the module `ActiveModel::Model`.
|
|
@@ -1155,14 +1202,14 @@ class User
|
|
|
1155
1202
|
end
|
|
1156
1203
|
```
|
|
1157
1204
|
|
|
1158
|
-
If you are using Presenters or Decorators that inherit from `SimpleDelegator` you can delegate
|
|
1205
|
+
If you are using Presenters or Decorators that inherit from `SimpleDelegator` you can delegate
|
|
1159
1206
|
it to the model.
|
|
1160
1207
|
|
|
1161
1208
|
```ruby
|
|
1162
1209
|
class UserPresenter < SimpleDelegator
|
|
1163
1210
|
# Without that, Simple Form will consider the user model as the object.
|
|
1164
|
-
def to_model
|
|
1165
|
-
self
|
|
1211
|
+
def to_model
|
|
1212
|
+
self
|
|
1166
1213
|
end
|
|
1167
1214
|
end
|
|
1168
1215
|
```
|
|
@@ -1170,7 +1217,7 @@ end
|
|
|
1170
1217
|
You can define all methods required by the helpers.
|
|
1171
1218
|
|
|
1172
1219
|
```ruby
|
|
1173
|
-
class User
|
|
1220
|
+
class User
|
|
1174
1221
|
extend ActiveModel::Naming
|
|
1175
1222
|
|
|
1176
1223
|
attr_accessor :id, :name
|
|
@@ -1179,25 +1226,25 @@ class User
|
|
|
1179
1226
|
self
|
|
1180
1227
|
end
|
|
1181
1228
|
|
|
1182
|
-
def to_key
|
|
1183
|
-
id
|
|
1229
|
+
def to_key
|
|
1230
|
+
id
|
|
1184
1231
|
end
|
|
1185
1232
|
|
|
1186
|
-
def persisted?
|
|
1187
|
-
false
|
|
1233
|
+
def persisted?
|
|
1234
|
+
false
|
|
1188
1235
|
end
|
|
1189
1236
|
end
|
|
1190
1237
|
```
|
|
1191
1238
|
|
|
1192
|
-
If your object doesn't implement those methods, you must make explicit it when you are
|
|
1239
|
+
If your object doesn't implement those methods, you must make explicit it when you are
|
|
1193
1240
|
building the form
|
|
1194
1241
|
|
|
1195
1242
|
```ruby
|
|
1196
|
-
class User
|
|
1243
|
+
class User
|
|
1197
1244
|
attr_accessor :id, :name
|
|
1198
1245
|
|
|
1199
1246
|
# The only method required to use the f.submit helper.
|
|
1200
|
-
def persisted?
|
|
1247
|
+
def persisted?
|
|
1201
1248
|
false
|
|
1202
1249
|
end
|
|
1203
1250
|
end
|
|
@@ -1205,25 +1252,25 @@ end
|
|
|
1205
1252
|
|
|
1206
1253
|
```erb
|
|
1207
1254
|
<%= simple_form_for(@user, as: :user, method: :post, url: users_path) do |f| %>
|
|
1208
|
-
<%= f.input :name %>
|
|
1255
|
+
<%= f.input :name %>
|
|
1209
1256
|
<%= f.submit 'New user' %>
|
|
1210
1257
|
<% end %>
|
|
1211
1258
|
```
|
|
1212
1259
|
|
|
1213
1260
|
## Information
|
|
1214
1261
|
|
|
1215
|
-
###
|
|
1262
|
+
### RDocs
|
|
1216
1263
|
|
|
1217
|
-
|
|
1218
|
-
Issues tracker:
|
|
1264
|
+
You can view the **Simple Form** documentation in RDoc format here:
|
|
1219
1265
|
|
|
1220
|
-
http://
|
|
1266
|
+
http://rubydoc.info/github/heartcombo/simple_form/main/frames
|
|
1221
1267
|
|
|
1222
|
-
###
|
|
1268
|
+
### Supported Ruby / Rails versions
|
|
1223
1269
|
|
|
1224
|
-
|
|
1270
|
+
We intend to maintain support for all Ruby / Rails versions that haven't reached end-of-life.
|
|
1225
1271
|
|
|
1226
|
-
|
|
1272
|
+
For more information about specific versions please check [Ruby](https://www.ruby-lang.org/en/downloads/branches/)
|
|
1273
|
+
and [Rails](https://guides.rubyonrails.org/maintenance_policy.html) maintenance policies, and our test matrix.
|
|
1227
1274
|
|
|
1228
1275
|
### Bug reports
|
|
1229
1276
|
|
|
@@ -1231,23 +1278,21 @@ If you discover any bugs, feel free to create an issue on GitHub. Please add as
|
|
|
1231
1278
|
possible to help us in fixing the potential bug. We also encourage you to help even more by forking and
|
|
1232
1279
|
sending us a pull request.
|
|
1233
1280
|
|
|
1234
|
-
https://github.com/
|
|
1281
|
+
https://github.com/heartcombo/simple_form/issues
|
|
1282
|
+
|
|
1283
|
+
If you have discovered a security related bug, please do NOT use the GitHub issue tracker. Send an e-mail to heartcombo@googlegroups.com.
|
|
1235
1284
|
|
|
1236
1285
|
## Maintainers
|
|
1237
1286
|
|
|
1238
|
-
* José Valim (https://github.com/josevalim)
|
|
1239
1287
|
* Carlos Antonio da Silva (https://github.com/carlosantoniodasilva)
|
|
1240
1288
|
* Rafael Mendonça França (https://github.com/rafaelfranca)
|
|
1241
|
-
*
|
|
1289
|
+
* Felipe Renan (https://github.com/feliperenan)
|
|
1242
1290
|
|
|
1243
1291
|
[](http://badge.fury.io/rb/simple_form)
|
|
1244
|
-
[](https://codeclimate.com/github/plataformatec/simple_form)
|
|
1246
|
-
[](http://inch-ci.org/github/plataformatec/simple_form)
|
|
1292
|
+
[](http://inch-ci.org/github/heartcombo/simple_form)
|
|
1247
1293
|
|
|
1248
1294
|
## License
|
|
1249
1295
|
|
|
1250
|
-
MIT License. Copyright 2009-2019 Plataformatec.
|
|
1296
|
+
MIT License. Copyright 2020-2023 Rafael França, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
|
|
1251
1297
|
|
|
1252
|
-
|
|
1253
|
-
limitation the Simple Form name or logo.
|
|
1298
|
+
The Simple Form logo is licensed under [Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License](https://creativecommons.org/licenses/by-nc-nd/4.0/).
|
|
@@ -5,12 +5,12 @@ module SimpleForm
|
|
|
5
5
|
desc "Copy SimpleForm default files"
|
|
6
6
|
source_root File.expand_path('../templates', __FILE__)
|
|
7
7
|
class_option :template_engine, desc: 'Template engine to be invoked (erb, haml or slim).'
|
|
8
|
-
class_option :bootstrap, type: :boolean, desc: 'Add the Bootstrap wrappers to the SimpleForm initializer.'
|
|
8
|
+
class_option :bootstrap, type: :boolean, desc: 'Add the Bootstrap 5 wrappers to the SimpleForm initializer.'
|
|
9
9
|
class_option :foundation, type: :boolean, desc: 'Add the Zurb Foundation 5 wrappers to the SimpleForm initializer.'
|
|
10
10
|
|
|
11
11
|
def info_bootstrap
|
|
12
12
|
return if options.bootstrap? || options.foundation?
|
|
13
|
-
puts "SimpleForm
|
|
13
|
+
puts "SimpleForm supports Bootstrap 5 and Zurb Foundation 5. If you want "\
|
|
14
14
|
"a configuration that is compatible with one of these frameworks, then please " \
|
|
15
15
|
"re-run this generator with --bootstrap or --foundation as an option."
|
|
16
16
|
end
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
Be sure to have a copy of the Bootstrap stylesheet available on your
|
|
4
4
|
application, you can get it on http://getbootstrap.com/.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
class, '.form-inline', as the following:
|
|
6
|
+
For usage examples and documentation, see:
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
https://simple-form-bootstrap.herokuapp.com
|
|
10
9
|
|
|
11
10
|
===============================================================================
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#
|
|
3
3
|
# Uncomment this and change the path if necessary to include your own
|
|
4
4
|
# components.
|
|
5
|
-
# See https://github.com/
|
|
5
|
+
# See https://github.com/heartcombo/simple_form#custom-components to know
|
|
6
6
|
# more about custom components.
|
|
7
7
|
# Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
|
|
8
8
|
#
|
|
@@ -112,7 +112,7 @@ SimpleForm.setup do |config|
|
|
|
112
112
|
# You can define the class to use on all labels. Default is nil.
|
|
113
113
|
# config.label_class = nil
|
|
114
114
|
|
|
115
|
-
# You can define the default class to be used on forms. Can be
|
|
115
|
+
# You can define the default class to be used on forms. Can be overridden
|
|
116
116
|
# with `html: { :class }`. Defaulting to none.
|
|
117
117
|
# config.default_form_class = nil
|
|
118
118
|
|