simple_form_awesome 2.2.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.
- data/CHANGELOG.md +327 -0
- data/MIT-LICENSE +20 -0
- data/README.md +25 -0
- data/lib/generators/simple_form/USAGE +3 -0
- data/lib/generators/simple_form/install_generator.rb +48 -0
- data/lib/generators/simple_form/templates/AUI_README +19 -0
- data/lib/generators/simple_form/templates/README +12 -0
- data/lib/generators/simple_form/templates/_form.html.erb +13 -0
- data/lib/generators/simple_form/templates/_form.html.haml +10 -0
- data/lib/generators/simple_form/templates/_form.html.slim +10 -0
- data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +142 -0
- data/lib/generators/simple_form/templates/config/initializers/simple_form_aui.rb +21 -0
- data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +45 -0
- data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +26 -0
- data/lib/generators/simple_form/templates/config/locales/simple_form.en.yml +26 -0
- data/lib/simple_form/action_view_extensions/builder.rb +340 -0
- data/lib/simple_form/action_view_extensions/form_helper.rb +72 -0
- data/lib/simple_form/components/errors.rb +35 -0
- data/lib/simple_form/components/hints.rb +18 -0
- data/lib/simple_form/components/html5.rb +26 -0
- data/lib/simple_form/components/label_input.rb +15 -0
- data/lib/simple_form/components/labels.rb +79 -0
- data/lib/simple_form/components/maxlength.rb +41 -0
- data/lib/simple_form/components/min_max.rb +50 -0
- data/lib/simple_form/components/pattern.rb +34 -0
- data/lib/simple_form/components/placeholders.rb +16 -0
- data/lib/simple_form/components/readonly.rb +22 -0
- data/lib/simple_form/components.rb +20 -0
- data/lib/simple_form/core_ext/hash.rb +16 -0
- data/lib/simple_form/error_notification.rb +48 -0
- data/lib/simple_form/form_builder.rb +482 -0
- data/lib/simple_form/helpers/autofocus.rb +11 -0
- data/lib/simple_form/helpers/disabled.rb +15 -0
- data/lib/simple_form/helpers/readonly.rb +15 -0
- data/lib/simple_form/helpers/required.rb +35 -0
- data/lib/simple_form/helpers/validators.rb +44 -0
- data/lib/simple_form/helpers.rb +12 -0
- data/lib/simple_form/i18n_cache.rb +22 -0
- data/lib/simple_form/inputs/aui_string_input.rb +10 -0
- data/lib/simple_form/inputs/base.rb +184 -0
- data/lib/simple_form/inputs/block_input.rb +14 -0
- data/lib/simple_form/inputs/boolean_input.rb +78 -0
- data/lib/simple_form/inputs/collection_check_boxes_input.rb +21 -0
- data/lib/simple_form/inputs/collection_input.rb +101 -0
- data/lib/simple_form/inputs/collection_radio_buttons_input.rb +63 -0
- data/lib/simple_form/inputs/collection_select_input.rb +14 -0
- data/lib/simple_form/inputs/date_time_input.rb +28 -0
- data/lib/simple_form/inputs/file_input.rb +9 -0
- data/lib/simple_form/inputs/grouped_collection_select_input.rb +41 -0
- data/lib/simple_form/inputs/hidden_input.rb +17 -0
- data/lib/simple_form/inputs/numeric_input.rb +24 -0
- data/lib/simple_form/inputs/password_input.rb +12 -0
- data/lib/simple_form/inputs/priority_input.rb +24 -0
- data/lib/simple_form/inputs/range_input.rb +14 -0
- data/lib/simple_form/inputs/string_input.rb +23 -0
- data/lib/simple_form/inputs/text_area_input.rb +12 -0
- data/lib/simple_form/inputs/text_input.rb +11 -0
- data/lib/simple_form/inputs.rb +23 -0
- data/lib/simple_form/map_type.rb +16 -0
- data/lib/simple_form/version.rb +3 -0
- data/lib/simple_form/wrappers/builder.rb +103 -0
- data/lib/simple_form/wrappers/many.rb +73 -0
- data/lib/simple_form/wrappers/root.rb +36 -0
- data/lib/simple_form/wrappers/single.rb +24 -0
- data/lib/simple_form/wrappers.rb +8 -0
- data/lib/simple_form.rb +221 -0
- data/test/action_view_extensions/builder_test.rb +583 -0
- data/test/action_view_extensions/form_helper_test.rb +143 -0
- data/test/components/label_test.rb +327 -0
- data/test/form_builder/association_test.rb +186 -0
- data/test/form_builder/button_test.rb +47 -0
- data/test/form_builder/error_notification_test.rb +79 -0
- data/test/form_builder/error_test.rb +121 -0
- data/test/form_builder/general_test.rb +402 -0
- data/test/form_builder/hint_test.rb +138 -0
- data/test/form_builder/input_field_test.rb +63 -0
- data/test/form_builder/label_test.rb +71 -0
- data/test/form_builder/wrapper_test.rb +203 -0
- data/test/generators/simple_form_generator_test.rb +42 -0
- data/test/inputs/boolean_input_test.rb +140 -0
- data/test/inputs/collection_check_boxes_input_test.rb +224 -0
- data/test/inputs/collection_radio_buttons_input_test.rb +326 -0
- data/test/inputs/collection_select_input_test.rb +241 -0
- data/test/inputs/datetime_input_test.rb +99 -0
- data/test/inputs/disabled_test.rb +78 -0
- data/test/inputs/discovery_test.rb +69 -0
- data/test/inputs/file_input_test.rb +16 -0
- data/test/inputs/general_test.rb +116 -0
- data/test/inputs/grouped_collection_select_input_test.rb +118 -0
- data/test/inputs/hidden_input_test.rb +30 -0
- data/test/inputs/numeric_input_test.rb +173 -0
- data/test/inputs/priority_input_test.rb +43 -0
- data/test/inputs/readonly_test.rb +101 -0
- data/test/inputs/required_test.rb +113 -0
- data/test/inputs/string_input_test.rb +146 -0
- data/test/inputs/text_input_test.rb +24 -0
- data/test/simple_form_test.rb +9 -0
- data/test/support/discovery_inputs.rb +27 -0
- data/test/support/misc_helpers.rb +138 -0
- data/test/support/mock_controller.rb +24 -0
- data/test/support/models.rb +216 -0
- data/test/test_helper.rb +95 -0
- metadata +217 -0
data/CHANGELOG.md
ADDED
@@ -0,0 +1,327 @@
|
|
1
|
+
## 2.1.0.dev
|
2
|
+
|
3
|
+
### enhancements
|
4
|
+
* Add Zurb Foundation 3 integration.
|
5
|
+
([@balexand](https://github/balexand))
|
6
|
+
* Generates additional wrapper class based on object + attribute name.
|
7
|
+
([@lucasmazza](https://github/lucasmazza))
|
8
|
+
Closes [#576](https://github.com/plataformatec/simple_form/issues/576).
|
9
|
+
|
10
|
+
### bug fix
|
11
|
+
* Do not lookup for hints if it was explicitly given false.
|
12
|
+
After #405 we added hint classes for the wrappers, but this has forced the
|
13
|
+
loading of the hint text doing I18n lookups, even though it was explicitly
|
14
|
+
given false. This checks for the option in `#has_hint?`, avoiding the lookup
|
15
|
+
in such cases. This issues has been caught with #627, thanks to
|
16
|
+
([@shwoodard](https://github.com/shwoodard)).
|
17
|
+
* Fix default I18n lookup for association input.
|
18
|
+
([@nashby](https://github.com/nashby))
|
19
|
+
Closes [#679](https://github.com/plataformatec/simple_form/issues/679).
|
20
|
+
* Fix escaping issue in `label_input` component
|
21
|
+
([@allomov](https://github.com/allomov))
|
22
|
+
|
23
|
+
## 2.0.4
|
24
|
+
|
25
|
+
### bug fix
|
26
|
+
|
27
|
+
* Remove invalid files from the gem package.
|
28
|
+
Closes [#673](https://github.com/plataformatec/simple_form/issues/673)
|
29
|
+
|
30
|
+
## 2.0.3
|
31
|
+
|
32
|
+
### enhancements
|
33
|
+
* Allow to specify custom wrappers for input types.
|
34
|
+
([@nashby](https://github.com/nashby))
|
35
|
+
Closes [#636](https://github.com/plataformatec/simple_form/issues/636)
|
36
|
+
* Use separate config file to do bootstrap specific configuration.
|
37
|
+
([@nashby](https://github.com/nashby))
|
38
|
+
|
39
|
+
### bug fix
|
40
|
+
* Allow to specify checked and uncked values for boolean input
|
41
|
+
([@nashby](https://github.com/nashby)).
|
42
|
+
Closes [#643](https://github.com/plataformatec/simple_form/issues/643)
|
43
|
+
* Allow to add additional classes only for wrapper.
|
44
|
+
([@nashby](https://github.com/nashby)).
|
45
|
+
Closes [#629](https://github.com/plataformatec/simple_form/issues/629)
|
46
|
+
* Boolean hidden field now respects `:name` attribute when nested.
|
47
|
+
([@amiel](https://github.com/amiel)).
|
48
|
+
Closes [#619](https://github.com/plataformatec/simple_form/issues/619)
|
49
|
+
* Prevent generation of `class=""`. ([@pkmiec](https://github.com/pkmiec))
|
50
|
+
* Fix namespace html propagation to single wrapper of `label` and `input`
|
51
|
+
* Association creates blank select if `:collection` is `nil`.
|
52
|
+
([@nashby](https://github.com/nashby)).
|
53
|
+
Closes [#595](https://github.com/plataformatec/simple_form/issues/595)
|
54
|
+
* Fix readonly attribute check. ([@retoo](https://github.com/retoo))
|
55
|
+
* Fix error when `collection_check_boxes` used with `form_for` instead of `simple_form_for`.
|
56
|
+
([@RohanM](https://github.com/RohanM))
|
57
|
+
* Ensure ActionView::Base.field_error_proc is preserved when exceptions occur within
|
58
|
+
`with_simple_form_field_error_proc`.
|
59
|
+
([@jim](https://github.com/jim))
|
60
|
+
* Handle array of strings in `:checked` option.
|
61
|
+
([@nashby](https://github.com/nashby))
|
62
|
+
|
63
|
+
## 2.0.2
|
64
|
+
|
65
|
+
### enhancements
|
66
|
+
* Add `:inline_label` option to nested booleans to display text inline with checkbox.
|
67
|
+
If the value is `true` it uses the default label text. ([@ehoch](https://github.com/ehoch))
|
68
|
+
* Add html support for hints. ([@findrails](https://github.com/findrails))
|
69
|
+
|
70
|
+
### bug fix
|
71
|
+
* Fix `min_max` component to not output maximum value. ([@julian7](https://github.com/julian7)).
|
72
|
+
Closes [#483](https://github.com/plataformatec/simple_form/issues/483)
|
73
|
+
* Remove leading and trailing whitespace from `label_text`.
|
74
|
+
Closes [#492](https://github.com/plataformatec/simple_form/issues/492)
|
75
|
+
* Fix checked radio button issue when value is false. ([@georgehemmings](https://github.com/georgehemmings)).
|
76
|
+
* Propagate defaults options to nested forms.
|
77
|
+
Closes [#553](https://github.com/plataformatec/simple_form/issues/533).
|
78
|
+
([@nashby](https://github.com/nashby))
|
79
|
+
* Fix limit and maxlength with decimal points. ([@shwoodard](https://github.com/shwoodard))
|
80
|
+
* Fix issue when html are duplicated.
|
81
|
+
Closes [#488](https://github.com/plataformatec/simple_form/issues/488).
|
82
|
+
([@ebonical](https://github.com/ebonical))
|
83
|
+
|
84
|
+
## 2.0.1
|
85
|
+
|
86
|
+
### bug fix
|
87
|
+
* Sanitaze html attributes to `label` method. ([@nashby](https://github.com/nashby)).
|
88
|
+
Closes [#472](https://github.com/plataformatec/simple_form/issues/472)
|
89
|
+
* Make `collection_check_boxes` and `collection_radio_buttons` work with local variables.
|
90
|
+
Closes [#474](https://github.com/plataformatec/simple_form/issues/474)
|
91
|
+
* Use `html5` component by default in the bootstrap generator. ([@isc](https://github.com/isc)).
|
92
|
+
Closes [#471](https://github.com/plataformatec/simple_form/issues/471)
|
93
|
+
|
94
|
+
## 2.0.0
|
95
|
+
|
96
|
+
### enhancements
|
97
|
+
* Add `button_class` configuration to change the class of buttons. ([@sryche](https://github.com/sryche))
|
98
|
+
* Add `disabled` class to a disabled input.
|
99
|
+
* Generate configuration file with `browser_validations` disabled.
|
100
|
+
* Add option and configuration to specify the collection wrapper class. ([@mfila](https://github.com/mfila))
|
101
|
+
* Add proc support to `collection` option. ([@jeffkreeftmeijer](https://github.com/jeffkreeftmeijer))
|
102
|
+
* `simple_form_for` allows default options for its inputs `:defaults => {}`.
|
103
|
+
* Add `readonly` as option of input method. ([@Untainted123](https://github.com/Untainted123))
|
104
|
+
* `simple_fields_for` for inherits wrapper option form the form builder. ([@nashby](https://github.com/nashby))
|
105
|
+
* Use action prefix in the form css class. Closes [#360](https://github.com/plataformatec/simple_form/issues/360).
|
106
|
+
This is not backward compatible with the previous versions of SimpleForm.
|
107
|
+
For more informations see [this comment](https://github.com/plataformatec/simple_form/issues/360#issuecomment-3000780).
|
108
|
+
([@nashby](https://github.com/nashby))
|
109
|
+
* Add a readonly component that does automatically readonly lookup from object
|
110
|
+
* Add support for proc or lambda as option for format validator ([@nashby](https://github.com/nashby))
|
111
|
+
* Handle validates_length_of :is option in maxlength ([@nashby](https://github.com/nashby))
|
112
|
+
* Add field_with_hint css class to the wrapper when the input has a hint, similar to field_with_errors ([@nashby](https://github.com/nashby))
|
113
|
+
* Add :grouped_select input type, mapping to Rails grouped_collection_select helper ([@semaperepelitsa](https://github.com/semaperepelitsa))
|
114
|
+
* Add automatic translation of options for collection inputs given a collection of symbols ([@klobuczek](https://github.com/klobuczek))
|
115
|
+
* Add `:boolean_style` config to change how check boxes and radios will be displayed.
|
116
|
+
Options are `:inline = input + label` (default) and `:nested = label > input`.
|
117
|
+
* Add possibility to give a block to `collection_radio` and `collection_check_boxes`,
|
118
|
+
yielding a custom builder to generate custom label and input structure. It
|
119
|
+
is used internally with the :nested option for `:boolean_style`, and is useful
|
120
|
+
to allow some more customization if required.
|
121
|
+
* Do not generate hidden check box field when using nested boolean style, as it is considered
|
122
|
+
invalid markup in HTML5. This will work by default in Rails > 3.2.1 (not released at this time),
|
123
|
+
and is backported inside SimpleForm builder extensions.
|
124
|
+
More info in [#215](https://github.com/plataformatec/simple_form/issues/215)
|
125
|
+
* Add `item_wrapper_class` configuration option for collection radio buttons / check boxes inputs.
|
126
|
+
* Change default generator templates to use .form-inputs and .form-actions classes in wrapper divs.
|
127
|
+
(the latter is the default in bootstrap, so this makes it easier to integrate).
|
128
|
+
* Field error now accepts HTML tags ([@edison](https://github.com/edison))
|
129
|
+
* Add `generate_additional_classes_for` config option to selectively disable extra
|
130
|
+
css classes for components - wrapper, label and input. ([krzyzak](https://github.com/krzyzak))
|
131
|
+
|
132
|
+
### deprecation
|
133
|
+
* Deprecate part of the old configuration API in favor of the wrapper API which allows you to customize your inputs
|
134
|
+
in a more flexible way. See [this guide](https://github.com/plataformatec/simple_form/wiki/Upgrading-to-Simple-Form-2.0)
|
135
|
+
to know how upgrade.
|
136
|
+
* Deprecate the `translate` configuration in favor of `translate_labels`
|
137
|
+
* Deprecate the `html5` configuration in favor of a new `html5` component
|
138
|
+
* Deprecate `:radio` input type in favor of `:radio_buttons`
|
139
|
+
* Deprecate `collection_radio` form helper in favor of `collection_radio_buttons`
|
140
|
+
(the label class has changed as well)
|
141
|
+
* Remove `error_notification_id` configuration
|
142
|
+
|
143
|
+
### bug fix
|
144
|
+
* Fix i18n lookup with attributes with same name of models.
|
145
|
+
Closes [#149](https://github.com/plataformatec/simple_form/issues/149)
|
146
|
+
and [#364](https://github.com/plataformatec/simple_form/issues/364).
|
147
|
+
([@nashby](https://github.com/nashby) and [@MarceloCajueiro](https://github.com/MarceloCajueiro))
|
148
|
+
* Do not generate `for` attribute for the collection label when it is a checkbox or radio.
|
149
|
+
Closes [#344](https://github.com/plataformatec/simple_form/issues/344).
|
150
|
+
([@nashby](https://github.com/nashby) and [@mfila](https://github.com/mfila))
|
151
|
+
* Select can have required option when the `:include_blank` option is passed.
|
152
|
+
Closes [#340](https://github.com/plataformatec/simple_form/issues/340). ([@nashby](https://github.com/nashby))
|
153
|
+
* `:checked` option should override the existing associations on `collection_check_boxes`.
|
154
|
+
Closes [#341](https://github.com/plataformatec/simple_form/issues/341). ([@nashby](https://github.com/nashby))
|
155
|
+
* Move default attribute translations out of root - use "defaults" key instead
|
156
|
+
Closes [#384](https://github.com/plataformatec/simple_form/issues/384). ([@fringd](https://github.com/fringd))
|
157
|
+
* Fix label to datetime inputs to point to first select. ([@georgehemmings](https://github.com/georgehemmings))
|
158
|
+
* Fix usage of f.button :button with Rails 3.2.
|
159
|
+
Closes [#449](https://github.com/plataformatec/simple_form/issues/449).
|
160
|
+
|
161
|
+
## 1.5.2
|
162
|
+
|
163
|
+
### bug fix
|
164
|
+
* Remove the internal usage of deprecated `:components`
|
165
|
+
|
166
|
+
## 1.5.1
|
167
|
+
|
168
|
+
### deprecation
|
169
|
+
* `:components` options is now deprecated
|
170
|
+
|
171
|
+
### bug fix
|
172
|
+
* Fallback to default label when block is provided. ([@pivotal-casebook](https://github.com/pivotal-casebook))
|
173
|
+
* Do not override default selection through attribute value in collection select when label/value methods are lambdas.
|
174
|
+
|
175
|
+
## 1.5.0
|
176
|
+
|
177
|
+
### enhancements
|
178
|
+
* Simplified generator by using directory action. ([@rupert654](https://github.com/rupert654))
|
179
|
+
* Support for `maxlength` on string inputs inferred from validation. ([@srbartlett](https://github.com/srbartlett))
|
180
|
+
* Change form css class handling to only add the dom class when one is not given to the form call.
|
181
|
+
([@patrick99e99](https://github.com/patrick99e99))
|
182
|
+
* Support for required attributes when action validations are present. ([@csegura](http://github.com/csegura))
|
183
|
+
* Do not generate `size` attribute for numeric input. ([@csegura](https://github.com/jasonmp85))
|
184
|
+
* Support for `maxlength` on text area inputs inferred from validation.
|
185
|
+
* Support for `pattern` on text field inferred from validation when `:pattern` is true.
|
186
|
+
* Break Text, Password and File into their own inputs.
|
187
|
+
* Support easy enabling and disabling of components for specific inputs.
|
188
|
+
* Add HTML5 range input.
|
189
|
+
|
190
|
+
### bug fix
|
191
|
+
* Fix bug when `simple_fields_for` is used with a hash like models and Rails 3.1.
|
192
|
+
* Fix bug that does not remove the `:item_wrapper_tag` or the `:collection_wrapper_tag` on collection
|
193
|
+
inputs when nil or false value is passed to these options. ([@dw2](https://gitbub.com/dw2))
|
194
|
+
* Fix bug that disable the entire select and wrapper when `disabled` option is a string or array.
|
195
|
+
* Fix bug when using label/value methods as procs together with disabled/selected options as procs for select inputs.
|
196
|
+
|
197
|
+
## 1.4.2
|
198
|
+
|
199
|
+
### enhancements
|
200
|
+
* Rails 3.1 support.
|
201
|
+
|
202
|
+
## 1.4.1
|
203
|
+
|
204
|
+
### enhancements
|
205
|
+
* ignore required attribute when conditional validations are present.
|
206
|
+
|
207
|
+
### bug fix
|
208
|
+
* Do not use `required='required'` when browser validations are turned off.
|
209
|
+
* Sanitize HMTL attributes in error and hint helpers when options are present.
|
210
|
+
* Improve i18n lookup by ignoring explicit child index given to form builder.
|
211
|
+
(tests by [@rywall](https://github.com/rywall))
|
212
|
+
* Fixes the form specific validation option if specified on the form itself. ([@medihack](https://github.com/medihack))
|
213
|
+
|
214
|
+
## 1.4.0
|
215
|
+
|
216
|
+
### enhancements
|
217
|
+
* Add label class configuration option. ([@reu](http://github.com/reu))
|
218
|
+
* Improve i18n lookup (labels/hints/placeholders) for nested models.
|
219
|
+
* Use the given custom builder with `simple_fields_for`. ([@giniedp](https://github.com/giniedp))
|
220
|
+
* Add slim form generator. ([@fagiani](https://github.com/fagiani))
|
221
|
+
* Add `form_class` configuration option. ([@fagiani](https://github.com/fagiani))
|
222
|
+
* Default step of `any` for number input with non integer attributes. ([@fedesoria](https://github.com/fedesoria))
|
223
|
+
* Add option to disable HTML5 browser validations on all forms. ([@coryschires](https://github.com/coryschires))
|
224
|
+
* Add option to disable all HTML5 extensions. ([@wolframarnold](https://github.com/wolframarnold))
|
225
|
+
* Add `input_field` helper to form builder. ([@jeroenhouben](https://github.com/jeroenhouben))
|
226
|
+
* Allow inputs to be discovered on demand by placing them at app/inputs (a la formtastic).
|
227
|
+
* Add `full_error` on that shows the error with the attribute name.
|
228
|
+
|
229
|
+
### bug fix
|
230
|
+
* Fix for file attributes automatic detection, to work with virtual attributes.
|
231
|
+
* Fix for numeric fields validation options using symbols and procs.
|
232
|
+
* Fix password attributes to add `size` and `maxlength` options the same way as string. ([@fedesoria](https://github.com/fedesoria))
|
233
|
+
* Fix bug with custom form builders and new mappings being added to the superclass builder. ([@rdvdijk](https://github.com/rdvdijk))
|
234
|
+
* Fix HTML validation issue with `collection_check_boxes`.
|
235
|
+
|
236
|
+
## 1.3.1
|
237
|
+
|
238
|
+
### enhancements
|
239
|
+
* Add `:autofocus` HTML5 attribute support. ([@jpzwarte](https://github.com/jpzwarte))
|
240
|
+
* Add possibility to specify custom builder and inherit mappings. ([@rejeep](https://github.com/rejeep))
|
241
|
+
* Make custom mappings work with all attributes types. ([@rafaelfranca](https://github.com/rafaelfranca))
|
242
|
+
* Add support for procs/lambdas in text/value methods for `collection_select`.
|
243
|
+
|
244
|
+
### deprecation
|
245
|
+
* removed the deprecated `:remote_form_for`
|
246
|
+
|
247
|
+
### bug fix
|
248
|
+
* Only add the `required` HTML 5 attribute for valid inputs, disable in selects (not allowed).
|
249
|
+
* Fix error when using hints without an attribute.
|
250
|
+
([@butsjoh](https://github.com/butsjoh) and [@rafaelfranca](https://github.com/rafaelfranca))
|
251
|
+
* Fix messy html output for hint, error and label components.
|
252
|
+
([@butsjoh](https://github.com/butsjoh) and [@rafaelfranca](https://github.com/rafaelfranca))
|
253
|
+
* Allow direct setting of for attribute on label. ([@Bertg](https://github.com/Bertg))
|
254
|
+
|
255
|
+
## 1.3.0
|
256
|
+
|
257
|
+
### enhancements
|
258
|
+
* Allow collection input to accept a collection of symbols.
|
259
|
+
* Add default css class to button.
|
260
|
+
* Allow forms for objects that do not respond to the `errors` method.
|
261
|
+
* `collection_check_boxes` and `collection_radio` now wrap the input in the label.
|
262
|
+
* Automatic add min/max values for numeric attributes based on validations and step for integers - HTML5.
|
263
|
+
([@dasch](https://github.com/dasch))
|
264
|
+
* Add `:placeholder` option for string inputs, allowing customization through I18n - HTML5.
|
265
|
+
([@jonathan](https://github.com/jonathan))
|
266
|
+
* Add `:search` and `:tel` input types, with `:tel` mapping automatically from attributes matching "phone" - HTML5.
|
267
|
+
* Add `:required` html attribute for required inputs - HTML5.
|
268
|
+
* Add optional `:components` option to input to control component rendering. ([@khoan](https://github.com/khoan))
|
269
|
+
* Add `SimpleForm.translate` as an easy way to turn off SimpleForm internal translations.
|
270
|
+
* Add `:disabled` option for all inputs. ([@fabiob](https://github.com/fabiob))
|
271
|
+
* Add collection wrapper tag and item wrapper tag to wrap elements in collection helpers - radio / check boxes.
|
272
|
+
* Add `SimpleForm.input_mappings` to allow configuring custom mappings for inputs. ([@TMaYaD](https://github.com/TMaYaD))
|
273
|
+
|
274
|
+
### bug fix
|
275
|
+
* Search for validations on both association and attribute.
|
276
|
+
* Use `controller.action_name` to lookup action only when available, to fix issue with Rspec views tests.
|
277
|
+
([@rafaelfranca](https://github.com/rafaelfranca))
|
278
|
+
|
279
|
+
## 1.2.2
|
280
|
+
|
281
|
+
### enhancements
|
282
|
+
* Compatibility with Rails 3 RC.
|
283
|
+
|
284
|
+
## 1.2.1
|
285
|
+
|
286
|
+
### enhancements
|
287
|
+
* Added haml generator support. ([@grimen](https://github.com/grimen))
|
288
|
+
* Added `error_notification` message to form builder.
|
289
|
+
* Added required by default as configuration option.
|
290
|
+
* Added `label_input` as component, allowing boolean to change its order (input appearing first than label).
|
291
|
+
* Added `error_method` to tidy up how errors are exhibited.
|
292
|
+
* Added error class on wrappers. ([@jduff](https://github.com/jduff))
|
293
|
+
* Changed numeric types to have `type=number` for HTML5.
|
294
|
+
|
295
|
+
## 1.2.0
|
296
|
+
|
297
|
+
### deprecation
|
298
|
+
* Changed `simple_form_install` generator to `simple_form:install`.
|
299
|
+
|
300
|
+
### enhancements
|
301
|
+
* Added support to presence validation to check if attribute is required or not. ([@gcirne](https://github.com/gcirne))
|
302
|
+
* Added `input` as class to wrapper tag.
|
303
|
+
* Added config options for hint and error tags. ([@tjogin](https://github.com/tjogin))
|
304
|
+
|
305
|
+
## 1.1.3
|
306
|
+
|
307
|
+
### deprecation
|
308
|
+
* removed `:conditions`, `:order`, `:joins` and `:include` support in `f.association`.
|
309
|
+
|
310
|
+
## 1.1.2
|
311
|
+
|
312
|
+
### bug fix
|
313
|
+
* Ensure type is set to "text" and not "string".
|
314
|
+
|
315
|
+
## 1.1.1
|
316
|
+
|
317
|
+
### bug fix
|
318
|
+
* Fix some escaping issues.
|
319
|
+
|
320
|
+
## 1.1.0
|
321
|
+
|
322
|
+
### enhancements
|
323
|
+
* Rails 3 support with generators, templates and HTML 5.
|
324
|
+
|
325
|
+
## 1.0
|
326
|
+
|
327
|
+
* First release.
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Plataformatec http://plataformatec.com.br/
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# SimpleForm - Rails forms made easy.
|
2
|
+
[](http://travis-ci.org/plataformatec/simple_form)
|
3
|
+
|
4
|
+
SimpleForm is really awesome, it supports bootstrap and Foundation yet. Now, i add AUI style to it,
|
5
|
+
be sure to have a copy of the AUI stylesheet available on your application, you can get it on
|
6
|
+
https://docs.atlassian.com/aui/latest . Enjoy it!
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add it to your Gemfile:
|
11
|
+
|
12
|
+
`gem 'simple_form_awesome'`
|
13
|
+
|
14
|
+
Run the following command to install it:
|
15
|
+
|
16
|
+
`bundle install`
|
17
|
+
|
18
|
+
Run the generator to install with AUI:
|
19
|
+
|
20
|
+
`rails generate simple_form:install --aui`
|
21
|
+
|
22
|
+
|
23
|
+
## License
|
24
|
+
|
25
|
+
MIT License. Copyright 2012 Plataformatec.
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module SimpleForm
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
desc "Copy SimpleForm default files"
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
class_option :template_engine, :desc => 'Template engine to be invoked (erb, haml or slim).'
|
7
|
+
class_option :bootstrap, :type => :boolean, :desc => 'Add the Twitter Bootstrap wrappers to the SimpleForm initializer.'
|
8
|
+
class_option :foundation, :type => :boolean, :desc => 'Add the Zurb Foundation 3 wrappers to the SimpleForm initializer.'
|
9
|
+
class_option :aui, :type => :boolean, :desc => 'Add the AUI wrappers to the SimpleForm initializer.'
|
10
|
+
|
11
|
+
def info_bootstrap
|
12
|
+
return if options.bootstrap? || options.foundation?
|
13
|
+
puts "SimpleForm 2 supports Twitter Bootstrap and Zurb Foundation 3. If you want "\
|
14
|
+
"a configuration that is compatible with one of these frameworks, then please " \
|
15
|
+
"re-run this generator with --bootstrap or --foundation as an option."
|
16
|
+
end
|
17
|
+
|
18
|
+
def copy_config
|
19
|
+
template "config/initializers/simple_form.rb"
|
20
|
+
|
21
|
+
if options[:bootstrap]
|
22
|
+
template "config/initializers/simple_form_bootstrap.rb"
|
23
|
+
elsif options[:foundation]
|
24
|
+
template "config/initializers/simple_form_foundation.rb"
|
25
|
+
elsif options[:aui]
|
26
|
+
template "config/initializers/simple_form_aui.rb"
|
27
|
+
end
|
28
|
+
|
29
|
+
directory 'config/locales'
|
30
|
+
end
|
31
|
+
|
32
|
+
def copy_scaffold_template
|
33
|
+
engine = options[:template_engine]
|
34
|
+
copy_file "_form.html.#{engine}", "lib/templates/#{engine}/scaffold/_form.html.#{engine}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def show_readme
|
38
|
+
if behavior == :invoke
|
39
|
+
if options.bootstrap?
|
40
|
+
readme "README"
|
41
|
+
elsif options.aui?
|
42
|
+
readme "AUI_README"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
===============================================================================
|
2
|
+
|
3
|
+
Be sure to have a copy of the AUI stylesheet available on your
|
4
|
+
application, you can get it on https://docs.atlassian.com/aui/latest
|
5
|
+
|
6
|
+
Inside your views, please add fieldset tag, and wrapper your submit or cancel
|
7
|
+
under a div that class is field_group
|
8
|
+
as the following:
|
9
|
+
|
10
|
+
= simple_form_for @user do |form|
|
11
|
+
%fieldset
|
12
|
+
= f.input :name, :as => :aui_string
|
13
|
+
= f.input :description, :as => :text_area
|
14
|
+
|
15
|
+
.field_group
|
16
|
+
= f.submit :class => "aui-button aui-button-primary"
|
17
|
+
= link_to "Cancel", "", :class => "aui-button aui-button-link"
|
18
|
+
|
19
|
+
===============================================================================
|
@@ -0,0 +1,12 @@
|
|
1
|
+
===============================================================================
|
2
|
+
|
3
|
+
Be sure to have a copy of the Bootstrap stylesheet available on your
|
4
|
+
application, you can get it on http://twitter.github.com/bootstrap.
|
5
|
+
|
6
|
+
Inside your views, use the 'simple_form_for' with one of the Bootstrap form
|
7
|
+
classes, '.form-horizontal', '.form-inline', '.form-search' or
|
8
|
+
'.form-vertical', as the following:
|
9
|
+
|
10
|
+
= simple_form_for(@user, :html => {:class => 'form-horizontal' }) do |form|
|
11
|
+
|
12
|
+
===============================================================================
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
|
2
|
+
<%%= f.error_notification %>
|
3
|
+
|
4
|
+
<div class="form-inputs">
|
5
|
+
<%- attributes.each do |attribute| -%>
|
6
|
+
<%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
|
7
|
+
<%- end -%>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="form-actions">
|
11
|
+
<%%= f.button :submit %>
|
12
|
+
</div>
|
13
|
+
<%% end %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
= simple_form_for(@<%= singular_table_name %>) do |f|
|
2
|
+
= f.error_notification
|
3
|
+
|
4
|
+
.form-inputs
|
5
|
+
<%- attributes.each do |attribute| -%>
|
6
|
+
= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %>
|
7
|
+
<%- end -%>
|
8
|
+
|
9
|
+
.form-actions
|
10
|
+
= f.button :submit
|
@@ -0,0 +1,10 @@
|
|
1
|
+
= simple_form_for(@<%= singular_table_name %>) do |f|
|
2
|
+
= f.error_notification
|
3
|
+
|
4
|
+
.form-inputs
|
5
|
+
<%- attributes.each do |attribute| -%>
|
6
|
+
= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %>
|
7
|
+
<%- end -%>
|
8
|
+
|
9
|
+
.form-actions
|
10
|
+
= f.button :submit
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# Use this setup block to configure all options available in SimpleForm.
|
2
|
+
SimpleForm.setup do |config|
|
3
|
+
# Wrappers are used by the form builder to generate a
|
4
|
+
# complete input. You can remove any component from the
|
5
|
+
# wrapper, change the order or even add your own to the
|
6
|
+
# stack. The options given below are used to wrap the
|
7
|
+
# whole input.
|
8
|
+
config.wrappers :default, :class => :input,
|
9
|
+
:hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
|
10
|
+
## Extensions enabled by default
|
11
|
+
# Any of these extensions can be disabled for a
|
12
|
+
# given input by passing: `f.input EXTENSION_NAME => false`.
|
13
|
+
# You can make any of these extensions optional by
|
14
|
+
# renaming `b.use` to `b.optional`.
|
15
|
+
|
16
|
+
# Determines whether to use HTML5 (:email, :url, ...)
|
17
|
+
# and required attributes
|
18
|
+
b.use :html5
|
19
|
+
|
20
|
+
# Calculates placeholders automatically from I18n
|
21
|
+
# You can also pass a string as f.input :placeholder => "Placeholder"
|
22
|
+
b.use :placeholder
|
23
|
+
|
24
|
+
## Optional extensions
|
25
|
+
# They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
|
26
|
+
# to the input. If so, they will retrieve the values from the model
|
27
|
+
# if any exists. If you want to enable the lookup for any of those
|
28
|
+
# extensions by default, you can change `b.optional` to `b.use`.
|
29
|
+
|
30
|
+
# Calculates maxlength from length validations for string inputs
|
31
|
+
b.optional :maxlength
|
32
|
+
|
33
|
+
# Calculates pattern from format validations for string inputs
|
34
|
+
b.optional :pattern
|
35
|
+
|
36
|
+
# Calculates min and max from length validations for numeric inputs
|
37
|
+
b.optional :min_max
|
38
|
+
|
39
|
+
# Calculates readonly automatically from readonly attributes
|
40
|
+
b.optional :readonly
|
41
|
+
|
42
|
+
## Inputs
|
43
|
+
b.use :label_input
|
44
|
+
b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
|
45
|
+
b.use :error, :wrap_with => { :tag => :span, :class => :error }
|
46
|
+
end
|
47
|
+
|
48
|
+
# The default wrapper to be used by the FormBuilder.
|
49
|
+
config.default_wrapper = :default
|
50
|
+
|
51
|
+
# Define the way to render check boxes / radio buttons with labels.
|
52
|
+
# Defaults to :nested for bootstrap config.
|
53
|
+
# :inline => input + label
|
54
|
+
# :nested => label > input
|
55
|
+
config.boolean_style = :nested
|
56
|
+
|
57
|
+
# Default class for buttons
|
58
|
+
config.button_class = 'btn'
|
59
|
+
|
60
|
+
# Method used to tidy up errors. Specify any Rails Array method.
|
61
|
+
# :first lists the first message for each field.
|
62
|
+
# Use :to_sentence to list all errors for each field.
|
63
|
+
# config.error_method = :first
|
64
|
+
|
65
|
+
# Default tag used for error notification helper.
|
66
|
+
config.error_notification_tag = :div
|
67
|
+
|
68
|
+
# CSS class to add for error notification helper.
|
69
|
+
config.error_notification_class = 'alert alert-error'
|
70
|
+
|
71
|
+
# ID to add for error notification helper.
|
72
|
+
# config.error_notification_id = nil
|
73
|
+
|
74
|
+
# Series of attempts to detect a default label method for collection.
|
75
|
+
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
76
|
+
|
77
|
+
# Series of attempts to detect a default value method for collection.
|
78
|
+
# config.collection_value_methods = [ :id, :to_s ]
|
79
|
+
|
80
|
+
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
81
|
+
# config.collection_wrapper_tag = nil
|
82
|
+
|
83
|
+
# You can define the class to use on all collection wrappers. Defaulting to none.
|
84
|
+
# config.collection_wrapper_class = nil
|
85
|
+
|
86
|
+
# You can wrap each item in a collection of radio/check boxes with a tag,
|
87
|
+
# defaulting to :span. Please note that when using :boolean_style = :nested,
|
88
|
+
# SimpleForm will force this option to be a label.
|
89
|
+
# config.item_wrapper_tag = :span
|
90
|
+
|
91
|
+
# You can define a class to use in all item wrappers. Defaulting to none.
|
92
|
+
# config.item_wrapper_class = nil
|
93
|
+
|
94
|
+
# How the label text should be generated altogether with the required text.
|
95
|
+
# config.label_text = lambda { |label, required| "#{required} #{label}" }
|
96
|
+
|
97
|
+
# You can define the class to use on all labels. Default is nil.
|
98
|
+
config.label_class = 'control-label'
|
99
|
+
|
100
|
+
# You can define the class to use on all forms. Default is simple_form.
|
101
|
+
# config.form_class = :simple_form
|
102
|
+
|
103
|
+
# You can define which elements should obtain additional classes
|
104
|
+
# config.generate_additional_classes_for = [:wrapper, :label, :input]
|
105
|
+
|
106
|
+
# Whether attributes are required by default (or not). Default is true.
|
107
|
+
# config.required_by_default = true
|
108
|
+
|
109
|
+
# Tell browsers whether to use default HTML5 validations (novalidate option).
|
110
|
+
# Default is enabled.
|
111
|
+
config.browser_validations = false
|
112
|
+
|
113
|
+
# Collection of methods to detect if a file type was given.
|
114
|
+
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
|
115
|
+
|
116
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
117
|
+
# to match as key, and the input type that will be used when the field name
|
118
|
+
# matches the regexp as value.
|
119
|
+
# config.input_mappings = { /count/ => :integer }
|
120
|
+
|
121
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
122
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
123
|
+
# config.wrapper_mappings = { :string => :prepend }
|
124
|
+
|
125
|
+
# Default priority for time_zone inputs.
|
126
|
+
# config.time_zone_priority = nil
|
127
|
+
|
128
|
+
# Default priority for country inputs.
|
129
|
+
# config.country_priority = nil
|
130
|
+
|
131
|
+
# Default size for text inputs.
|
132
|
+
# config.default_input_size = 50
|
133
|
+
|
134
|
+
# When false, do not use translations for labels.
|
135
|
+
# config.translate_labels = true
|
136
|
+
|
137
|
+
# Automatically discover new inputs in Rails' autoload path.
|
138
|
+
# config.inputs_discovery = true
|
139
|
+
|
140
|
+
# Cache SimpleForm inputs discovery
|
141
|
+
# config.cache_discovery = !Rails.env.development?
|
142
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# No prepend and append wrappers, sorry for that.
|
2
|
+
|
3
|
+
SimpleForm.setup do |config|
|
4
|
+
config.wrappers :aui, :tag => 'div', :class => "field-group", :errors_class => "error" do |b|
|
5
|
+
b.use :html5
|
6
|
+
b.use :placeholder
|
7
|
+
b.use :readonly
|
8
|
+
b.use :maxlength
|
9
|
+
b.use :label
|
10
|
+
b.use :input
|
11
|
+
b.use :tag => 'div', :class => "description" do |input|
|
12
|
+
input.use :hint
|
13
|
+
end
|
14
|
+
b.use :tag => 'div', :class => "error" do |input|
|
15
|
+
input.use :error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
config.default_wrapper = :aui
|
20
|
+
config.form_class = :aui
|
21
|
+
end
|