simple_form 3.0.1 → 4.0.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.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +149 -25
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +441 -107
  5. data/lib/generators/simple_form/install_generator.rb +4 -3
  6. data/lib/generators/simple_form/templates/README +4 -5
  7. data/lib/generators/simple_form/templates/_form.html.erb +2 -0
  8. data/lib/generators/simple_form/templates/_form.html.haml +2 -0
  9. data/lib/generators/simple_form/templates/_form.html.slim +1 -0
  10. data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +48 -11
  11. data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +417 -23
  12. data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +101 -5
  13. data/lib/generators/simple_form/templates/config/locales/simple_form.en.yml +7 -2
  14. data/lib/simple_form/action_view_extensions/builder.rb +2 -0
  15. data/lib/simple_form/action_view_extensions/form_helper.rb +10 -3
  16. data/lib/simple_form/components/errors.rb +38 -3
  17. data/lib/simple_form/components/hints.rb +3 -2
  18. data/lib/simple_form/components/html5.rb +16 -5
  19. data/lib/simple_form/components/label_input.rb +21 -2
  20. data/lib/simple_form/components/labels.rb +22 -11
  21. data/lib/simple_form/components/maxlength.rb +9 -5
  22. data/lib/simple_form/components/min_max.rb +2 -1
  23. data/lib/simple_form/components/minlength.rb +38 -0
  24. data/lib/simple_form/components/pattern.rb +2 -1
  25. data/lib/simple_form/components/placeholders.rb +4 -3
  26. data/lib/simple_form/components/readonly.rb +2 -1
  27. data/lib/simple_form/components.rb +2 -0
  28. data/lib/simple_form/error_notification.rb +1 -0
  29. data/lib/simple_form/form_builder.rb +193 -80
  30. data/lib/simple_form/helpers/autofocus.rb +1 -0
  31. data/lib/simple_form/helpers/disabled.rb +1 -0
  32. data/lib/simple_form/helpers/readonly.rb +1 -0
  33. data/lib/simple_form/helpers/required.rb +1 -0
  34. data/lib/simple_form/helpers/validators.rb +2 -1
  35. data/lib/simple_form/helpers.rb +6 -5
  36. data/lib/simple_form/i18n_cache.rb +1 -0
  37. data/lib/simple_form/inputs/base.rb +57 -14
  38. data/lib/simple_form/inputs/block_input.rb +2 -1
  39. data/lib/simple_form/inputs/boolean_input.rb +39 -16
  40. data/lib/simple_form/inputs/collection_check_boxes_input.rb +2 -1
  41. data/lib/simple_form/inputs/collection_input.rb +37 -14
  42. data/lib/simple_form/inputs/collection_radio_buttons_input.rb +9 -13
  43. data/lib/simple_form/inputs/collection_select_input.rb +5 -2
  44. data/lib/simple_form/inputs/date_time_input.rb +24 -9
  45. data/lib/simple_form/inputs/file_input.rb +5 -2
  46. data/lib/simple_form/inputs/grouped_collection_select_input.rb +16 -3
  47. data/lib/simple_form/inputs/hidden_input.rb +5 -2
  48. data/lib/simple_form/inputs/numeric_input.rb +6 -4
  49. data/lib/simple_form/inputs/password_input.rb +6 -3
  50. data/lib/simple_form/inputs/priority_input.rb +5 -2
  51. data/lib/simple_form/inputs/range_input.rb +2 -1
  52. data/lib/simple_form/inputs/string_input.rb +6 -3
  53. data/lib/simple_form/inputs/text_input.rb +6 -3
  54. data/lib/simple_form/inputs.rb +1 -0
  55. data/lib/simple_form/map_type.rb +1 -0
  56. data/lib/simple_form/railtie.rb +8 -0
  57. data/lib/simple_form/tags.rb +7 -0
  58. data/lib/simple_form/version.rb +2 -1
  59. data/lib/simple_form/wrappers/builder.rb +7 -6
  60. data/lib/simple_form/wrappers/leaf.rb +29 -0
  61. data/lib/simple_form/wrappers/many.rb +7 -6
  62. data/lib/simple_form/wrappers/root.rb +3 -1
  63. data/lib/simple_form/wrappers/single.rb +7 -4
  64. data/lib/simple_form/wrappers.rb +2 -0
  65. data/lib/simple_form.rb +117 -18
  66. data/test/action_view_extensions/builder_test.rb +42 -41
  67. data/test/action_view_extensions/form_helper_test.rb +36 -16
  68. data/test/components/custom_components_test.rb +62 -0
  69. data/test/components/label_test.rb +70 -41
  70. data/test/form_builder/association_test.rb +79 -37
  71. data/test/form_builder/button_test.rb +11 -10
  72. data/test/form_builder/error_notification_test.rb +2 -1
  73. data/test/form_builder/error_test.rb +173 -24
  74. data/test/form_builder/general_test.rb +171 -73
  75. data/test/form_builder/hint_test.rb +24 -18
  76. data/test/form_builder/input_field_test.rb +132 -56
  77. data/test/form_builder/label_test.rb +68 -13
  78. data/test/form_builder/wrapper_test.rb +190 -22
  79. data/test/generators/simple_form_generator_test.rb +8 -7
  80. data/test/inputs/boolean_input_test.rb +89 -6
  81. data/test/inputs/collection_check_boxes_input_test.rb +109 -25
  82. data/test/inputs/collection_radio_buttons_input_test.rb +168 -54
  83. data/test/inputs/collection_select_input_test.rb +183 -77
  84. data/test/inputs/datetime_input_test.rb +131 -50
  85. data/test/inputs/disabled_test.rb +16 -15
  86. data/test/inputs/discovery_test.rb +58 -6
  87. data/test/inputs/file_input_test.rb +3 -2
  88. data/test/inputs/general_test.rb +23 -22
  89. data/test/inputs/grouped_collection_select_input_test.rb +54 -17
  90. data/test/inputs/hidden_input_test.rb +5 -4
  91. data/test/inputs/numeric_input_test.rb +48 -44
  92. data/test/inputs/priority_input_test.rb +23 -14
  93. data/test/inputs/readonly_test.rb +20 -19
  94. data/test/inputs/required_test.rb +58 -13
  95. data/test/inputs/string_input_test.rb +62 -33
  96. data/test/inputs/text_input_test.rb +20 -7
  97. data/test/simple_form_test.rb +9 -0
  98. data/test/support/discovery_inputs.rb +33 -2
  99. data/test/support/misc_helpers.rb +113 -5
  100. data/test/support/mock_controller.rb +7 -1
  101. data/test/support/models.rb +137 -37
  102. data/test/test_helper.rb +15 -1
  103. metadata +25 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16a083a7be892436f572b9e055699a94d889d8ca
4
- data.tar.gz: 5240794b73edefddc037c5a528f3a5eb362fb7bc
3
+ metadata.gz: bdc43deadddaaf9bc4b3872855d677c5e560066d
4
+ data.tar.gz: 1a58416a2a4977e825f25c345ba41abec78c85a9
5
5
  SHA512:
6
- metadata.gz: 54cfce6263962c3918d36467a0681dc31e48262a777110c2e05ebf4f8daa8bf2ce8c0dec773c9cf37d60af34f424936d09766e34ccb98572780c0f877d9051b8
7
- data.tar.gz: 70d460b6f6f5467aa84b599ffc5e1cdbb59b6b581d5cc51ac064c2f2100b1ed70f1550073db7ca3670a4955a2a33a49657b81a3c70b6e3bdccef1a0ab88227e4
6
+ metadata.gz: 9812df086c46e0abe897274ac1260cac8dccb7d906da88f75182efc741a4802931f0c5c8b556dfa1ab0793cf93fe9cd68909d69948cee1f43f26b7a807e3ae29
7
+ data.tar.gz: dca2a8eaf706656f77f5294a18068521aa83a9ab2fbd1e269009e68751e9ea2d2811127d5daa017d137c5c9ec5c74b62bbfaaa3fb002211f6778d09cb19a066c
data/CHANGELOG.md CHANGED
@@ -1,32 +1,156 @@
1
- ## 3.0.1
1
+ ## Unreleased
2
+
3
+ ## 4.0.0
4
+
5
+ ### Enhancements
6
+ * Add bootstrap v4.1 generator template. [@m5o](https://github.com/m5o)
7
+ * Add Rails 5.2 support. [@gobijan](https://github.com/gobijan)
8
+ * Add API to register custom components.[@feliperenan](https://github.com/feliperenan)
9
+ * Allow custom errors classes to inputs.[@feliperenan](https://github.com/feliperenan)
10
+ * Remove support from Rails 4.0, 4.1 and 4.2. [@feliperenan](https://github.com/feliperenan)
11
+ * Add support for citext, hstore, json & jsonb column types. [@swrobel](https://github.com/swrobel)
12
+ * Add :valid_class on input wrapper when value is present and valid [@aeberlin](https://github.com/aeberlin), [@m5o](https://github.com/m5o)
13
+ * Allow :valid_class to inputs when value is present and valid. [@m5o](https://github.com/m5o)
14
+ * Allow validation classes on input_field. [@feliperenan](https://github.com/feliperenan)
15
+ * Add basic ActiveStorage support. [@murb](https://github.com/murb)
16
+
17
+ ### Bug fix
18
+ * Fix horizontal form label position, from right to text-right. [@cavpollo](https://github.com/cavpollo)
19
+ * Add base error display alongside existing errors. [@bluefalcon26](https://github.com/bluefalcon26)
20
+ * Silent deprication warning for placeholder_text. [@moofkit](https://github.com/moofkit)
21
+ * Use custom i18n scope for label required html. [@tvdeyen](https://github.com/tvdeyen)
22
+
23
+ ## 3.5.1
24
+
25
+ ### Enhancements
26
+ * Exclude hidden field when unchecked_value: false. [@fschwahn](https://github.com/fschwahn)
27
+ * Add frozen_string_literal magic comment to several files. [@oniofchaos](https://github.com/oniofchaos)
28
+ * Try convert @object to model in case we got decorated object [@timurvafin](https://github.com/timurvafin)
29
+ - From now, if you are using some object that inherits from `SimpleDelegator`, you must implement
30
+ `def to_model; self; end`. Otherwise, *Simple Form* will convert the decorated object to the model
31
+ since `SimpleDelegator` will delegate it to the model.
32
+ * Code cleanup [@Fornacula](https://github.com/Fornacula)
33
+
34
+ ### Bug fix
35
+ * Fix error when the scope from association has parameter. [@feliperenan](https://github.com/feliperenan)
36
+ * Only call `where` on associations when they respond to it. [@anicholson](https://github.com/anicholson)
37
+ * require 'action_pack' before using it. [@etagwerker](https://github.com/etagwerker)
38
+ * Check if Rails.env is defined. [@etagwerker](https://github.com/etagwerker)
39
+ * Fix minlength. [@mameier](https://github.com/mameier)
40
+ * Make errors_on_attribute return [] when not present. [@redrick](https://github.com/redrick)
41
+ * Fix boolean inputs in nested style for label non-string. [@feliperenan](https://github.com/feliperenan)
42
+
43
+ ## 3.5.0
44
+
45
+ * Updated gem dependency to support Rails 5.1.x.
46
+
47
+ ## 3.4.0
48
+
49
+ * Removed Ruby 2.4.0 `Integer` unification deprecation warning.
50
+ * Removed EOL Ruby 1.9.3 from the build matrix.
51
+ * Added `minlength` component.
52
+ * `boolean_label_class` can be set on a per-input basis.
53
+
54
+ ## 3.3.1
55
+
56
+ ### Bug fix
57
+
58
+ * Fix support for symbols when looking up types with `ActiveModel::Type`.
59
+
60
+ ## 3.3.0
61
+
62
+ ### enhancements
63
+ * Add the `aria-invalid` attribute on inputs with errors.
64
+ * Added support for the new `ActiveModel::Type` API over Active Record's
65
+ column objects.
2
66
 
3
67
  ### bug fix
4
- * Fix XSS vulnerability on label, hint and error components.
68
+ * Fix `merge_wrapper_options` to correctly merge options with duplicated keys. [@herminiotorres](https://github.com/herminiotorres)
69
+ Closes [#1278](https://github.com/plataformatec/simple_form/issues/1278).
5
70
 
6
- ## 3.0.0
71
+ ## 3.2.1
7
72
 
8
73
  ### enhancements
9
- * New `input_class` global config option to set a class to be generated in all inputs.
10
- * Collection tags accept html attributes as the last element of collection [@nashby](https://github.com/nashby)
11
- * Change default `:value_method` of collection tags from `:last` to `:second` [@nashby](https://github.com/nashby)
12
- * Support `Proc` object in `:conditions` option of associations [@bradly](https://github.com/bradly)
13
- * `input_field` supports `html5` component [@nashby](https://github.com/nashby)
14
- * Make `field_error_proc` configurable [@dfens](https://github.com/dfens)
15
- * Support to Rails 4.
16
- * Removed deprecated methods.
17
- * SimpleForm no longer sets the `size` attribute automatically and the `default_input_size` setting
18
- is now deprecated.
19
- * Support to aria-required attribute to required fields [@ckundo](https://github.com/ckundo)
74
+ * Updated gem dependency to support Rails 5.0.x.
75
+
76
+ ## 3.2.0
20
77
 
21
78
  ### bug fix
22
- * Make `DateTimeInput#label_target` method to work with string values in `I18n.t('date.order')` (default
23
- behaviour in Rails 4)
24
- Closes [#846](https://github.com/plataformatec/simple_form/issues/846) [@mjankowski](https://github.com/mjankowski)
25
- * Add "checkbox" class to the label of boolean input when there is no `:label`
26
- in `generate_additional_classes_for` config option [@nashby](https://github.com/nashby)
27
- * Support models with digits in their names [@webgago](https://github.com/webgago)
28
- * Remove deprecation warnings related to `Relation#all` from Rails 4.
29
- * Form builder can be used outside the context of a controller [@jasonwebster](https://github.com/jasonwebster)
30
- * Skip pattern attribute when using `validates_format_of` with `:without` option [@glebm](https://github.com/glebm)
31
-
32
- Please check [v2.1](https://github.com/plataformatec/simple_form/blob/v2.1/CHANGELOG.md) for previous changes.
79
+ * Improve performance of input generation by disabling support for `_html` translations. This reverts the feature introduced on the 3.1.0 branch
80
+
81
+ ## 3.1.1
82
+
83
+ ### enhancements
84
+ * Add the `disabled_class` to the label when the input is disabled. [@rhodrid](https://github.com/rhodrid)
85
+
86
+ ### bug fix
87
+ * Make it possible to override `required` value that was previously set in the wrapper. [@nashby](https://github.com/nashby)
88
+
89
+ * `date/time/datetime` inputs now correctly generate the label `for` attribute when
90
+ HTML5 compatibility is explicitly enabled. [@ericsullivan](https://github.com/ericsullivan)
91
+
92
+ * The datetime, date, and time inputs now have a nice format by default on bootstrap.
93
+ [@ulissesalmeida](https://github.com/ulissesalmeida) [@eltonchrls](https://github.com/eltonchrls)
94
+
95
+ * Now it is possible to set custom input mappings for collections.
96
+
97
+ Example:
98
+
99
+ ```ruby
100
+ # On configuration:
101
+ config.input_mappings = { /gender$/ => :check_boxes }
102
+
103
+ # On form:
104
+ f.input :gender, collection: [:male, :female]
105
+ ```
106
+ [strangeworks](https://github.com/strangeworks)
107
+
108
+ ## 3.1.0
109
+
110
+ ### enhancements
111
+ * Update foundation generator to version 5. [@jorge-d](https://github.com/jorge-d)
112
+ * Add mapping to `uuid` columns.
113
+ * Add custom namespaces for custom inputs feature. [@vala](https://github.com/vala)
114
+ * Add `:unless_blank` option to the wrapper API. [@IanVaughan](https://github.com/IanVaughan)
115
+ * Add support to html markup in the I18n options. [@laurocaetano](https://github.com/laurocaetano)
116
+ * Add the `full_error` component. [@laurocaetano](https://github.com/laurocaetano)
117
+ * Add support to `scope` to be used on associations. [@laurocaetano](https://github.com/laurocaetano)
118
+ * Execute the association `condition` in the object context. [@laurocaetano](https://github.com/laurocaetano)
119
+ * Check if the given association responds to `order` before calling it. [@laurocaetano](https://github.com/laurocaetano)
120
+ * Add Bootstrap 3 initializer template.
121
+ * For radio or checkbox collection always use `:item_wrapper_tag` to wrap the content and add `label` when using `boolean_style` with `:nested` [@kassio](https://github.com/kassio) and [@erichkist](https://github.com/erichkist)
122
+ * `input_field` uses the same wrapper as input but only with attribute components. [@nashby](https://github.com/nashby)
123
+ * Add wrapper mapping per form basis [@rcillo](https://github.com/rcillo) and [@bernardoamc](https://github.com/bernardoamc)
124
+ * Add `for` attribute to `label` when collections are rendered as radio or checkbox [@erichkist](https://github.com/erichkist), [@ulissesalmeida](https://github.com/ulissesalmeida) and [@fabioyamate](https://github.com/fabioyamate)
125
+ * Add `include_default_input_wrapper_class` config [@luizcosta](https://github.com/luizcosta)
126
+ * Map `datetime`, `date` and `time` input types to their respective HTML5 input tags
127
+ when the `:html5` is set to `true` [@volmer](https://github.com/volmer)
128
+ * Add `boolean_label_class` config.
129
+ * Add `:html` option to include additional attributes on custom wrappers [@remofritzsche](https://github.com/remofritzsche) and [@ulissesalmeida](https://github.com/ulissesalmeida)
130
+ * Make possible to use the Wrappers API to define attributes for the components.
131
+ See https://github.com/plataformatec/simple_form/pull/997 for more information.
132
+ * Put a whitespace before the `inline_label` options of boolean input if it is present.
133
+ * Add support to configure the `label_text` proc at the wrapper level. [@NOX73](https://github.com/NOX73)
134
+ * `label_text` proc now receive three arguments (label, request, and if the label was explicit). [@timscott](https://github.com/timscott)
135
+ * Add I18n support to `:include_blank` and `:prompt` when `:translate` is used as value. [@haines](https://github.com/plataformatec/simple_form/pull/616)
136
+ * Add support to define custom error messages for the attributes.
137
+ * Add support to change the I18n scope to be used in Simple Form. [@nielsbuus](https://github.com/nielsbuus)
138
+ * The default form class can now be overridden with `html: { :class }`. [@rmm5t](https://github.com/rmm5t)
139
+
140
+ ### bug fix
141
+ * Fix `full_error` when the attribute is an association. [@mvdamme](https://github.com/jorge-d)
142
+ * Fix suppport to `:namespace` and `:index` options for nested check boxes and radio buttons when the attribute is an association.
143
+ * Collection input that uses automatic collection translation properly sets checked values.
144
+ Closes [#971](https://github.com/plataformatec/simple_form/issues/971) [@nashby](https://github.com/nashby)
145
+ * Collection input generates `required` attribute if it has `prompt` option. [@nashby](https://github.com/nashby)
146
+ * Grouped collection uses the first non-empty object to detect label and value methods.
147
+
148
+ ## deprecation
149
+ * Methods on custom inputs now accept a required argument with the wrapper options.
150
+ See https://github.com/plataformatec/simple_form/pull/997 for more information.
151
+ * SimpleForm.form_class is deprecated in favor of SimpleForm.default_form_class.
152
+ Future versions of Simple Form will not generate `simple_form` class for the form
153
+ element.
154
+ See https://github.com/plataformatec/simple_form/pull/1109 for more information.
155
+
156
+ Please check [v3.0](https://github.com/plataformatec/simple_form/blob/v3.0/CHANGELOG.md) for previous changes.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009-2013 Plataformatec http://plataformatec.com.br/
1
+ Copyright (c) 2009-2016 Plataformatec http://plataformatec.com.br/
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the