tiny-smart-mod 0.0.1

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.
Files changed (70) hide show
  1. checksums.yaml +7 -0
  2. data/simple_form-5.4.1/CHANGELOG.md +259 -0
  3. data/simple_form-5.4.1/MIT-LICENSE +21 -0
  4. data/simple_form-5.4.1/README.md +1334 -0
  5. data/simple_form-5.4.1/lib/generators/simple_form/USAGE +3 -0
  6. data/simple_form-5.4.1/lib/generators/simple_form/install_generator.rb +190 -0
  7. data/simple_form-5.4.1/lib/generators/simple_form/templates/README +10 -0
  8. data/simple_form-5.4.1/lib/generators/simple_form/templates/_form.html.erb +15 -0
  9. data/simple_form-5.4.1/lib/generators/simple_form/templates/_form.html.haml +12 -0
  10. data/simple_form-5.4.1/lib/generators/simple_form/templates/_form.html.slim +11 -0
  11. data/simple_form-5.4.1/lib/generators/simple_form/templates/config/initializers/simple_form.rb +176 -0
  12. data/simple_form-5.4.1/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +372 -0
  13. data/simple_form-5.4.1/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +122 -0
  14. data/simple_form-5.4.1/lib/generators/simple_form/templates/config/locales/simple_form.en.yml +31 -0
  15. data/simple_form-5.4.1/lib/simple_form/action_view_extensions/builder.rb +38 -0
  16. data/simple_form-5.4.1/lib/simple_form/action_view_extensions/form_helper.rb +72 -0
  17. data/simple_form-5.4.1/lib/simple_form/components/errors.rb +74 -0
  18. data/simple_form-5.4.1/lib/simple_form/components/hints.rb +24 -0
  19. data/simple_form-5.4.1/lib/simple_form/components/html5.rb +33 -0
  20. data/simple_form-5.4.1/lib/simple_form/components/label_input.rb +34 -0
  21. data/simple_form-5.4.1/lib/simple_form/components/labels.rb +88 -0
  22. data/simple_form-5.4.1/lib/simple_form/components/maxlength.rb +35 -0
  23. data/simple_form-5.4.1/lib/simple_form/components/min_max.rb +41 -0
  24. data/simple_form-5.4.1/lib/simple_form/components/minlength.rb +35 -0
  25. data/simple_form-5.4.1/lib/simple_form/components/pattern.rb +27 -0
  26. data/simple_form-5.4.1/lib/simple_form/components/placeholders.rb +17 -0
  27. data/simple_form-5.4.1/lib/simple_form/components/readonly.rb +23 -0
  28. data/simple_form-5.4.1/lib/simple_form/components.rb +24 -0
  29. data/simple_form-5.4.1/lib/simple_form/error_notification.rb +49 -0
  30. data/simple_form-5.4.1/lib/simple_form/form_builder.rb +723 -0
  31. data/simple_form-5.4.1/lib/simple_form/helpers/autofocus.rb +12 -0
  32. data/simple_form-5.4.1/lib/simple_form/helpers/disabled.rb +16 -0
  33. data/simple_form-5.4.1/lib/simple_form/helpers/readonly.rb +16 -0
  34. data/simple_form-5.4.1/lib/simple_form/helpers/required.rb +36 -0
  35. data/simple_form-5.4.1/lib/simple_form/helpers/validators.rb +66 -0
  36. data/simple_form-5.4.1/lib/simple_form/helpers.rb +13 -0
  37. data/simple_form-5.4.1/lib/simple_form/inputs/base.rb +232 -0
  38. data/simple_form-5.4.1/lib/simple_form/inputs/block_input.rb +15 -0
  39. data/simple_form-5.4.1/lib/simple_form/inputs/boolean_input.rb +108 -0
  40. data/simple_form-5.4.1/lib/simple_form/inputs/collection_check_boxes_input.rb +22 -0
  41. data/simple_form-5.4.1/lib/simple_form/inputs/collection_input.rb +122 -0
  42. data/simple_form-5.4.1/lib/simple_form/inputs/collection_radio_buttons_input.rb +59 -0
  43. data/simple_form-5.4.1/lib/simple_form/inputs/collection_select_input.rb +17 -0
  44. data/simple_form-5.4.1/lib/simple_form/inputs/color_input.rb +14 -0
  45. data/simple_form-5.4.1/lib/simple_form/inputs/date_time_input.rb +39 -0
  46. data/simple_form-5.4.1/lib/simple_form/inputs/file_input.rb +12 -0
  47. data/simple_form-5.4.1/lib/simple_form/inputs/grouped_collection_select_input.rb +54 -0
  48. data/simple_form-5.4.1/lib/simple_form/inputs/hidden_input.rb +20 -0
  49. data/simple_form-5.4.1/lib/simple_form/inputs/numeric_input.rb +20 -0
  50. data/simple_form-5.4.1/lib/simple_form/inputs/password_input.rb +14 -0
  51. data/simple_form-5.4.1/lib/simple_form/inputs/priority_input.rb +37 -0
  52. data/simple_form-5.4.1/lib/simple_form/inputs/range_input.rb +15 -0
  53. data/simple_form-5.4.1/lib/simple_form/inputs/rich_text_area_input.rb +14 -0
  54. data/simple_form-5.4.1/lib/simple_form/inputs/string_input.rb +25 -0
  55. data/simple_form-5.4.1/lib/simple_form/inputs/text_input.rb +14 -0
  56. data/simple_form-5.4.1/lib/simple_form/inputs/weekday_input.rb +14 -0
  57. data/simple_form-5.4.1/lib/simple_form/inputs.rb +27 -0
  58. data/simple_form-5.4.1/lib/simple_form/map_type.rb +17 -0
  59. data/simple_form-5.4.1/lib/simple_form/railtie.rb +19 -0
  60. data/simple_form-5.4.1/lib/simple_form/tags.rb +73 -0
  61. data/simple_form-5.4.1/lib/simple_form/version.rb +4 -0
  62. data/simple_form-5.4.1/lib/simple_form/wrappers/builder.rb +80 -0
  63. data/simple_form-5.4.1/lib/simple_form/wrappers/leaf.rb +29 -0
  64. data/simple_form-5.4.1/lib/simple_form/wrappers/many.rb +74 -0
  65. data/simple_form-5.4.1/lib/simple_form/wrappers/root.rb +43 -0
  66. data/simple_form-5.4.1/lib/simple_form/wrappers/single.rb +27 -0
  67. data/simple_form-5.4.1/lib/simple_form/wrappers.rb +10 -0
  68. data/simple_form-5.4.1/lib/simple_form.rb +340 -0
  69. data/tiny-smart-mod.gemspec +12 -0
  70. metadata +109 -0
@@ -0,0 +1,372 @@
1
+ # frozen_string_literal: true
2
+
3
+ # These defaults are defined and maintained by the community at
4
+ # https://github.com/heartcombo/simple_form-bootstrap
5
+ # Please submit feedback, changes and tests only there.
6
+
7
+ # Uncomment this and change the path if necessary to include your own
8
+ # components.
9
+ # See https://github.com/heartcombo/simple_form#custom-components
10
+ # to know more about custom components.
11
+ # Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
12
+
13
+ # Use this setup block to configure all options available in SimpleForm.
14
+ SimpleForm.setup do |config|
15
+ # Default class for buttons
16
+ config.button_class = 'btn'
17
+
18
+ # Define the default class of the input wrapper of the boolean input.
19
+ config.boolean_label_class = 'form-check-label'
20
+
21
+ # How the label text should be generated altogether with the required text.
22
+ config.label_text = lambda { |label, required, explicit_label| "#{label} #{required}" }
23
+
24
+ # Define the way to render check boxes / radio buttons with labels.
25
+ config.boolean_style = :inline
26
+
27
+ # You can wrap each item in a collection of radio/check boxes with a tag
28
+ config.item_wrapper_tag = :div
29
+
30
+ # Defines if the default input wrapper class should be included in radio
31
+ # collection wrappers.
32
+ config.include_default_input_wrapper_class = false
33
+
34
+ # CSS class to add for error notification helper.
35
+ config.error_notification_class = 'alert alert-danger'
36
+
37
+ # Method used to tidy up errors. Specify any Rails Array method.
38
+ # :first lists the first message for each field.
39
+ # :to_sentence to list all errors for each field.
40
+ config.error_method = :to_sentence
41
+
42
+ # add validation classes to `input_field`
43
+ config.input_field_error_class = 'is-invalid'
44
+ config.input_field_valid_class = 'is-valid'
45
+
46
+
47
+ # vertical forms
48
+ #
49
+ # vertical default_wrapper
50
+ config.wrappers :vertical_form, class: 'mb-3' do |b|
51
+ b.use :html5
52
+ b.use :placeholder
53
+ b.optional :maxlength
54
+ b.optional :minlength
55
+ b.optional :pattern
56
+ b.optional :min_max
57
+ b.optional :readonly
58
+ b.use :label, class: 'form-label'
59
+ b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
60
+ b.use :full_error, wrap_with: { class: 'invalid-feedback' }
61
+ b.use :hint, wrap_with: { class: 'form-text' }
62
+ end
63
+
64
+ # vertical input for boolean
65
+ config.wrappers :vertical_boolean, tag: 'fieldset', class: 'mb-3' do |b|
66
+ b.use :html5
67
+ b.optional :readonly
68
+ b.wrapper :form_check_wrapper, class: 'form-check' do |bb|
69
+ bb.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
70
+ bb.use :label, class: 'form-check-label'
71
+ bb.use :full_error, wrap_with: { class: 'invalid-feedback' }
72
+ bb.use :hint, wrap_with: { class: 'form-text' }
73
+ end
74
+ end
75
+
76
+ # vertical input for radio buttons and check boxes
77
+ config.wrappers :vertical_collection, item_wrapper_class: 'form-check', item_label_class: 'form-check-label', tag: 'fieldset', class: 'mb-3' do |b|
78
+ b.use :html5
79
+ b.optional :readonly
80
+ b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
81
+ ba.use :label_text
82
+ end
83
+ b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
84
+ b.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
85
+ b.use :hint, wrap_with: { class: 'form-text' }
86
+ end
87
+
88
+ # vertical input for inline radio buttons and check boxes
89
+ config.wrappers :vertical_collection_inline, item_wrapper_class: 'form-check form-check-inline', item_label_class: 'form-check-label', tag: 'fieldset', class: 'mb-3' do |b|
90
+ b.use :html5
91
+ b.optional :readonly
92
+ b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
93
+ ba.use :label_text
94
+ end
95
+ b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
96
+ b.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
97
+ b.use :hint, wrap_with: { class: 'form-text' }
98
+ end
99
+
100
+ # vertical file input
101
+ config.wrappers :vertical_file, class: 'mb-3' do |b|
102
+ b.use :html5
103
+ b.use :placeholder
104
+ b.optional :maxlength
105
+ b.optional :minlength
106
+ b.optional :readonly
107
+ b.use :label, class: 'form-label'
108
+ b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
109
+ b.use :full_error, wrap_with: { class: 'invalid-feedback' }
110
+ b.use :hint, wrap_with: { class: 'form-text' }
111
+ end
112
+
113
+ # vertical select input
114
+ config.wrappers :vertical_select, class: 'mb-3' do |b|
115
+ b.use :html5
116
+ b.optional :readonly
117
+ b.use :label, class: 'form-label'
118
+ b.use :input, class: 'form-select', error_class: 'is-invalid', valid_class: 'is-valid'
119
+ b.use :full_error, wrap_with: { class: 'invalid-feedback' }
120
+ b.use :hint, wrap_with: { class: 'form-text' }
121
+ end
122
+
123
+ # vertical multi select
124
+ config.wrappers :vertical_multi_select, class: 'mb-3' do |b|
125
+ b.use :html5
126
+ b.optional :readonly
127
+ b.use :label, class: 'form-label'
128
+ b.wrapper class: 'd-flex flex-row justify-content-between align-items-center' do |ba|
129
+ ba.use :input, class: 'form-select mx-1', error_class: 'is-invalid', valid_class: 'is-valid'
130
+ end
131
+ b.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
132
+ b.use :hint, wrap_with: { class: 'form-text' }
133
+ end
134
+
135
+ # vertical range input
136
+ config.wrappers :vertical_range, class: 'mb-3' do |b|
137
+ b.use :html5
138
+ b.use :placeholder
139
+ b.optional :readonly
140
+ b.optional :step
141
+ b.use :label, class: 'form-label'
142
+ b.use :input, class: 'form-range', error_class: 'is-invalid', valid_class: 'is-valid'
143
+ b.use :full_error, wrap_with: { class: 'invalid-feedback' }
144
+ b.use :hint, wrap_with: { class: 'form-text' }
145
+ end
146
+
147
+
148
+ # horizontal forms
149
+ #
150
+ # horizontal default_wrapper
151
+ config.wrappers :horizontal_form, class: 'row mb-3' do |b|
152
+ b.use :html5
153
+ b.use :placeholder
154
+ b.optional :maxlength
155
+ b.optional :minlength
156
+ b.optional :pattern
157
+ b.optional :min_max
158
+ b.optional :readonly
159
+ b.use :label, class: 'col-sm-3 col-form-label'
160
+ b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
161
+ ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
162
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback' }
163
+ ba.use :hint, wrap_with: { class: 'form-text' }
164
+ end
165
+ end
166
+
167
+ # horizontal input for boolean
168
+ config.wrappers :horizontal_boolean, class: 'row mb-3' do |b|
169
+ b.use :html5
170
+ b.optional :readonly
171
+ b.wrapper :grid_wrapper, class: 'col-sm-9 offset-sm-3' do |wr|
172
+ wr.wrapper :form_check_wrapper, class: 'form-check' do |bb|
173
+ bb.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
174
+ bb.use :label, class: 'form-check-label'
175
+ bb.use :full_error, wrap_with: { class: 'invalid-feedback' }
176
+ bb.use :hint, wrap_with: { class: 'form-text' }
177
+ end
178
+ end
179
+ end
180
+
181
+ # horizontal input for radio buttons and check boxes
182
+ config.wrappers :horizontal_collection, item_wrapper_class: 'form-check', item_label_class: 'form-check-label', class: 'row mb-3' do |b|
183
+ b.use :html5
184
+ b.optional :readonly
185
+ b.use :label, class: 'col-sm-3 col-form-label pt-0'
186
+ b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
187
+ ba.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
188
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
189
+ ba.use :hint, wrap_with: { class: 'form-text' }
190
+ end
191
+ end
192
+
193
+ # horizontal input for inline radio buttons and check boxes
194
+ config.wrappers :horizontal_collection_inline, item_wrapper_class: 'form-check form-check-inline', item_label_class: 'form-check-label', class: 'row mb-3' do |b|
195
+ b.use :html5
196
+ b.optional :readonly
197
+ b.use :label, class: 'col-sm-3 col-form-label pt-0'
198
+ b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
199
+ ba.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
200
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
201
+ ba.use :hint, wrap_with: { class: 'form-text' }
202
+ end
203
+ end
204
+
205
+ # horizontal file input
206
+ config.wrappers :horizontal_file, class: 'row mb-3' do |b|
207
+ b.use :html5
208
+ b.use :placeholder
209
+ b.optional :maxlength
210
+ b.optional :minlength
211
+ b.optional :readonly
212
+ b.use :label, class: 'col-sm-3 col-form-label'
213
+ b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
214
+ ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
215
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback' }
216
+ ba.use :hint, wrap_with: { class: 'form-text' }
217
+ end
218
+ end
219
+
220
+ # horizontal select input
221
+ config.wrappers :horizontal_select, class: 'row mb-3' do |b|
222
+ b.use :html5
223
+ b.optional :readonly
224
+ b.use :label, class: 'col-sm-3 col-form-label'
225
+ b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
226
+ ba.use :input, class: 'form-select', error_class: 'is-invalid', valid_class: 'is-valid'
227
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback' }
228
+ ba.use :hint, wrap_with: { class: 'form-text' }
229
+ end
230
+ end
231
+
232
+ # horizontal multi select
233
+ config.wrappers :horizontal_multi_select, class: 'row mb-3' do |b|
234
+ b.use :html5
235
+ b.optional :readonly
236
+ b.use :label, class: 'col-sm-3 col-form-label'
237
+ b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
238
+ ba.wrapper class: 'd-flex flex-row justify-content-between align-items-center' do |bb|
239
+ bb.use :input, class: 'form-select mx-1', error_class: 'is-invalid', valid_class: 'is-valid'
240
+ end
241
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
242
+ ba.use :hint, wrap_with: { class: 'form-text' }
243
+ end
244
+ end
245
+
246
+ # horizontal range input
247
+ config.wrappers :horizontal_range, class: 'row mb-3' do |b|
248
+ b.use :html5
249
+ b.use :placeholder
250
+ b.optional :readonly
251
+ b.optional :step
252
+ b.use :label, class: 'col-sm-3 col-form-label pt-0'
253
+ b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
254
+ ba.use :input, class: 'form-range', error_class: 'is-invalid', valid_class: 'is-valid'
255
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback' }
256
+ ba.use :hint, wrap_with: { class: 'form-text' }
257
+ end
258
+ end
259
+
260
+
261
+ # inline forms
262
+ #
263
+ # inline default_wrapper
264
+ config.wrappers :inline_form, class: 'col-12' do |b|
265
+ b.use :html5
266
+ b.use :placeholder
267
+ b.optional :maxlength
268
+ b.optional :minlength
269
+ b.optional :pattern
270
+ b.optional :min_max
271
+ b.optional :readonly
272
+ b.use :label, class: 'visually-hidden'
273
+
274
+ b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
275
+ b.use :error, wrap_with: { class: 'invalid-feedback' }
276
+ b.optional :hint, wrap_with: { class: 'form-text' }
277
+ end
278
+
279
+ # inline input for boolean
280
+ config.wrappers :inline_boolean, class: 'col-12' do |b|
281
+ b.use :html5
282
+ b.optional :readonly
283
+ b.wrapper :form_check_wrapper, class: 'form-check' do |bb|
284
+ bb.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
285
+ bb.use :label, class: 'form-check-label'
286
+ bb.use :error, wrap_with: { class: 'invalid-feedback' }
287
+ bb.optional :hint, wrap_with: { class: 'form-text' }
288
+ end
289
+ end
290
+
291
+
292
+ # bootstrap custom forms
293
+ #
294
+ # custom input switch for boolean
295
+ config.wrappers :custom_boolean_switch, class: 'mb-3' do |b|
296
+ b.use :html5
297
+ b.optional :readonly
298
+ b.wrapper :form_check_wrapper, tag: 'div', class: 'form-check form-switch' do |bb|
299
+ bb.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
300
+ bb.use :label, class: 'form-check-label'
301
+ bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
302
+ bb.use :hint, wrap_with: { class: 'form-text' }
303
+ end
304
+ end
305
+
306
+
307
+ # Input Group - custom component
308
+ # see example app and config at https://github.com/heartcombo/simple_form-bootstrap
309
+ config.wrappers :input_group, class: 'mb-3' do |b|
310
+ b.use :html5
311
+ b.use :placeholder
312
+ b.optional :maxlength
313
+ b.optional :minlength
314
+ b.optional :pattern
315
+ b.optional :min_max
316
+ b.optional :readonly
317
+ b.use :label, class: 'form-label'
318
+ b.wrapper :input_group_tag, class: 'input-group' do |ba|
319
+ ba.optional :prepend
320
+ ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
321
+ ba.optional :append
322
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback' }
323
+ end
324
+ b.use :hint, wrap_with: { class: 'form-text' }
325
+ end
326
+
327
+
328
+ # Floating Labels form
329
+ #
330
+ # floating labels default_wrapper
331
+ config.wrappers :floating_labels_form, class: 'form-floating mb-3' do |b|
332
+ b.use :html5
333
+ b.use :placeholder
334
+ b.optional :maxlength
335
+ b.optional :minlength
336
+ b.optional :pattern
337
+ b.optional :min_max
338
+ b.optional :readonly
339
+ b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
340
+ b.use :label
341
+ b.use :full_error, wrap_with: { class: 'invalid-feedback' }
342
+ b.use :hint, wrap_with: { class: 'form-text' }
343
+ end
344
+
345
+ # custom multi select
346
+ config.wrappers :floating_labels_select, class: 'form-floating mb-3' do |b|
347
+ b.use :html5
348
+ b.optional :readonly
349
+ b.use :input, class: 'form-select', error_class: 'is-invalid', valid_class: 'is-valid'
350
+ b.use :label
351
+ b.use :full_error, wrap_with: { class: 'invalid-feedback' }
352
+ b.use :hint, wrap_with: { class: 'form-text' }
353
+ end
354
+
355
+
356
+ # The default wrapper to be used by the FormBuilder.
357
+ config.default_wrapper = :vertical_form
358
+
359
+ # Custom wrappers for input types. This should be a hash containing an input
360
+ # type as key and the wrapper that will be used for all inputs with specified type.
361
+ config.wrapper_mappings = {
362
+ boolean: :vertical_boolean,
363
+ check_boxes: :vertical_collection,
364
+ date: :vertical_multi_select,
365
+ datetime: :vertical_multi_select,
366
+ file: :vertical_file,
367
+ radio_buttons: :vertical_collection,
368
+ range: :vertical_range,
369
+ time: :vertical_multi_select,
370
+ select: :vertical_select
371
+ }
372
+ end
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Uncomment this and change the path if necessary to include your own
4
+ # components.
5
+ # See https://github.com/heartcombo/simple_form#custom-components to know
6
+ # more about custom components.
7
+ # Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
8
+ #
9
+ # Use this setup block to configure all options available in SimpleForm.
10
+ SimpleForm.setup do |config|
11
+ # Don't forget to edit this file to adapt it to your needs (specially
12
+ # all the grid-related classes)
13
+ #
14
+ # Please note that hints are commented out by default since Foundation
15
+ # doesn't provide styles for hints. You will need to provide your own CSS styles for hints.
16
+ # Uncomment them to enable hints.
17
+
18
+ config.wrappers :vertical_form, class: :input, hint_class: :field_with_hint, error_class: :error, valid_class: :valid do |b|
19
+ b.use :html5
20
+ b.use :placeholder
21
+ b.optional :maxlength
22
+ b.optional :minlength
23
+ b.optional :pattern
24
+ b.optional :min_max
25
+ b.optional :readonly
26
+ b.use :label_input
27
+ b.use :error, wrap_with: { tag: :small, class: :error }
28
+
29
+ # b.use :hint, wrap_with: { tag: :span, class: :hint }
30
+ end
31
+
32
+ config.wrappers :horizontal_form, tag: 'div', class: 'row', hint_class: :field_with_hint, error_class: :error, valid_class: :valid do |b|
33
+ b.use :html5
34
+ b.use :placeholder
35
+ b.optional :maxlength
36
+ b.optional :minlength
37
+ b.optional :pattern
38
+ b.optional :min_max
39
+ b.optional :readonly
40
+
41
+ b.wrapper :label_wrapper, tag: :div, class: 'small-3 columns' do |ba|
42
+ ba.use :label, class: 'text-right inline'
43
+ end
44
+
45
+ b.wrapper :right_input_wrapper, tag: :div, class: 'small-9 columns' do |ba|
46
+ ba.use :input
47
+ ba.use :error, wrap_with: { tag: :small, class: :error }
48
+ # ba.use :hint, wrap_with: { tag: :span, class: :hint }
49
+ end
50
+ end
51
+
52
+ config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'row' do |b|
53
+ b.use :html5
54
+ b.optional :readonly
55
+
56
+ b.wrapper :container_wrapper, tag: 'div', class: 'small-offset-3 small-9 columns' do |ba|
57
+ ba.wrapper tag: 'label', class: 'checkbox' do |bb|
58
+ bb.use :input
59
+ bb.use :label_text
60
+ end
61
+
62
+ ba.use :error, wrap_with: { tag: :small, class: :error }
63
+ # ba.use :hint, wrap_with: { tag: :span, class: :hint }
64
+ end
65
+ end
66
+
67
+ # Foundation does not provide a way to handle inline forms
68
+ # This wrapper can be used to create an inline form
69
+ # by hiding that labels on every screen sizes ('hidden-for-small-up').
70
+ #
71
+ # Note that you need to adapt this wrapper to your needs. If you need a 4
72
+ # columns form then change the wrapper class to 'small-3', if you need
73
+ # only two use 'small-6' and so on.
74
+ config.wrappers :inline_form, tag: 'div', class: 'column small-4', hint_class: :field_with_hint, error_class: :error, valid_class: :valid do |b|
75
+ b.use :html5
76
+ b.use :placeholder
77
+ b.optional :maxlength
78
+ b.optional :minlength
79
+ b.optional :pattern
80
+ b.optional :min_max
81
+ b.optional :readonly
82
+
83
+ b.use :label, class: 'hidden-for-small-up'
84
+ b.use :input
85
+
86
+ b.use :error, wrap_with: { tag: :small, class: :error }
87
+ # b.use :hint, wrap_with: { tag: :span, class: :hint }
88
+ end
89
+
90
+ # Examples of use:
91
+ # - wrapper_html: {class: 'row'}, custom_wrapper_html: {class: 'column small-12'}
92
+ # - custom_wrapper_html: {class: 'column small-3 end'}
93
+ config.wrappers :customizable_wrapper, tag: 'div', error_class: :error, valid_class: :valid do |b|
94
+ b.use :html5
95
+ b.optional :readonly
96
+
97
+ b.wrapper :custom_wrapper, tag: :div do |ba|
98
+ ba.use :label_input
99
+ end
100
+
101
+ b.use :error, wrap_with: { tag: :small, class: :error }
102
+ # b.use :hint, wrap_with: { tag: :span, class: :hint }
103
+ end
104
+
105
+ # CSS class for buttons
106
+ config.button_class = 'button'
107
+
108
+ # Set this to div to make the checkbox and radio properly work
109
+ # otherwise simple_form adds a label tag instead of a div around
110
+ # the nested label
111
+ config.item_wrapper_tag = :div
112
+
113
+ # CSS class to add for error notification helper.
114
+ config.error_notification_class = 'alert-box alert'
115
+
116
+ # The default wrapper to be used by the FormBuilder.
117
+ config.default_wrapper = :vertical_form
118
+
119
+ # Defines validation classes to the input_field. By default it's nil.
120
+ # config.input_field_valid_class = 'is-valid'
121
+ # config.input_field_error_class = 'is-invalid'
122
+ end
@@ -0,0 +1,31 @@
1
+ en:
2
+ simple_form:
3
+ "yes": 'Yes'
4
+ "no": 'No'
5
+ required:
6
+ text: 'required'
7
+ mark: '*'
8
+ # You can uncomment the line below if you need to overwrite the whole required html.
9
+ # When using html, text and mark won't be used.
10
+ # html: '<abbr title="required">*</abbr>'
11
+ error_notification:
12
+ default_message: "Please review the problems below:"
13
+ # Examples
14
+ # labels:
15
+ # defaults:
16
+ # password: 'Password'
17
+ # user:
18
+ # new:
19
+ # email: 'E-mail to sign in.'
20
+ # edit:
21
+ # email: 'E-mail.'
22
+ # hints:
23
+ # defaults:
24
+ # username: 'User name to sign in.'
25
+ # password: 'No special characters, please.'
26
+ # include_blanks:
27
+ # defaults:
28
+ # age: 'Rather not say'
29
+ # prompts:
30
+ # defaults:
31
+ # age: 'Select your age'
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+ module SimpleForm
3
+ module ActionViewExtensions
4
+ # A collection of methods required by simple_form but added to rails default form.
5
+ # This means that you can use such methods outside simple_form context.
6
+ module Builder
7
+
8
+ # Wrapper for using SimpleForm inside a default rails form.
9
+ # Example:
10
+ #
11
+ # form_for @user do |f|
12
+ # f.simple_fields_for :posts do |posts_form|
13
+ # # Here you have all simple_form methods available
14
+ # posts_form.input :title
15
+ # end
16
+ # end
17
+ def simple_fields_for(*args, &block)
18
+ options = args.extract_options!
19
+ options[:wrapper] = self.options[:wrapper] if options[:wrapper].nil?
20
+ options[:defaults] ||= self.options[:defaults]
21
+ options[:wrapper_mappings] ||= self.options[:wrapper_mappings]
22
+
23
+ if self.class < ActionView::Helpers::FormBuilder
24
+ options[:builder] ||= self.class
25
+ else
26
+ options[:builder] ||= SimpleForm::FormBuilder
27
+ end
28
+ fields_for(*args, options, &block)
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ module ActionView::Helpers
35
+ class FormBuilder
36
+ include SimpleForm::ActionViewExtensions::Builder
37
+ end
38
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+ module SimpleForm
3
+ module ActionViewExtensions
4
+ # This module creates SimpleForm wrappers around default form_for and fields_for.
5
+ #
6
+ # Example:
7
+ #
8
+ # simple_form_for @user do |f|
9
+ # f.input :name, hint: 'My hint'
10
+ # end
11
+ #
12
+ module FormHelper
13
+
14
+ def simple_form_for(record, options = {}, &block)
15
+ options[:builder] ||= SimpleForm::FormBuilder
16
+ options[:html] ||= {}
17
+ unless options[:html].key?(:novalidate)
18
+ options[:html][:novalidate] = !SimpleForm.browser_validations
19
+ end
20
+ if options[:html].key?(:class)
21
+ options[:html][:class] = [SimpleForm.form_class, options[:html][:class]].compact
22
+ else
23
+ options[:html][:class] = [SimpleForm.form_class, SimpleForm.default_form_class, simple_form_css_class(record, options)].compact
24
+ end
25
+
26
+ with_simple_form_field_error_proc do
27
+ form_for(record, options, &block)
28
+ end
29
+ end
30
+
31
+ def simple_fields_for(record_name, record_object = nil, options = {}, &block)
32
+ options, record_object = record_object, nil if record_object.is_a?(Hash) && record_object.extractable_options?
33
+ options[:builder] ||= SimpleForm::FormBuilder
34
+
35
+ with_simple_form_field_error_proc do
36
+ fields_for(record_name, record_object, options, &block)
37
+ end
38
+ end
39
+
40
+ private
41
+
42
+ def with_simple_form_field_error_proc
43
+ default_field_error_proc = ::ActionView::Base.field_error_proc
44
+ begin
45
+ ::ActionView::Base.field_error_proc = SimpleForm.field_error_proc
46
+ yield
47
+ ensure
48
+ ::ActionView::Base.field_error_proc = default_field_error_proc
49
+ end
50
+ end
51
+
52
+ def simple_form_css_class(record, options)
53
+ html_options = options[:html]
54
+ as = options[:as]
55
+
56
+ if html_options.key?(:class)
57
+ html_options[:class]
58
+ elsif record.is_a?(String) || record.is_a?(Symbol)
59
+ as || record
60
+ else
61
+ record = record.last if record.is_a?(Array)
62
+ action = record.respond_to?(:persisted?) && record.persisted? ? :edit : :new
63
+ as ? "#{action}_#{as}" : dom_class(record, action)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ ActiveSupport.on_load(:action_view) do
71
+ include SimpleForm::ActionViewExtensions::FormHelper
72
+ end