formtastic 4.0.0 → 6.0.0.alpha

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 (171) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/integration.yaml +36 -0
  3. data/.github/workflows/test.yml +31 -25
  4. data/.gitignore +2 -1
  5. data/Appraisals +23 -0
  6. data/CHANGELOG.md +28 -1
  7. data/CONTRIBUTING.md +27 -0
  8. data/Gemfile +5 -0
  9. data/MIT-LICENSE +1 -1
  10. data/README.md +14 -41
  11. data/Rakefile +1 -1
  12. data/formtastic.gemspec +18 -9
  13. data/gemfiles/rails_72.gemfile +9 -0
  14. data/gemfiles/rails_80.gemfile +9 -0
  15. data/gemfiles/rails_81.gemfile +9 -0
  16. data/gemfiles/rails_edge.gemfile +9 -0
  17. data/lib/formtastic/action_class_finder.rb +1 -0
  18. data/lib/formtastic/actions/base.rb +1 -0
  19. data/lib/formtastic/actions/button_action.rb +1 -0
  20. data/lib/formtastic/actions/buttonish.rb +1 -0
  21. data/lib/formtastic/actions/input_action.rb +1 -0
  22. data/lib/formtastic/actions/link_action.rb +1 -0
  23. data/lib/formtastic/actions.rb +1 -0
  24. data/lib/formtastic/deprecation.rb +2 -1
  25. data/lib/formtastic/form_builder.rb +26 -25
  26. data/lib/formtastic/helpers/action_helper.rb +1 -1
  27. data/lib/formtastic/helpers/actions_helper.rb +1 -0
  28. data/lib/formtastic/helpers/enum.rb +1 -0
  29. data/lib/formtastic/helpers/errors_helper.rb +72 -14
  30. data/lib/formtastic/helpers/fieldset_wrapper.rb +1 -0
  31. data/lib/formtastic/helpers/file_column_detection.rb +1 -0
  32. data/lib/formtastic/helpers/form_helper.rb +1 -0
  33. data/lib/formtastic/helpers/input_helper.rb +6 -6
  34. data/lib/formtastic/helpers/inputs_helper.rb +2 -1
  35. data/lib/formtastic/helpers/reflection.rb +1 -0
  36. data/lib/formtastic/helpers.rb +1 -1
  37. data/lib/formtastic/html_attributes.rb +1 -0
  38. data/lib/formtastic/i18n.rb +1 -1
  39. data/lib/formtastic/input_class_finder.rb +1 -0
  40. data/lib/formtastic/inputs/base/aria.rb +26 -0
  41. data/lib/formtastic/inputs/base/associations.rb +1 -0
  42. data/lib/formtastic/inputs/base/choices.rb +2 -1
  43. data/lib/formtastic/inputs/base/collections.rb +5 -2
  44. data/lib/formtastic/inputs/base/database.rb +5 -7
  45. data/lib/formtastic/inputs/base/datetime_pickerish.rb +1 -0
  46. data/lib/formtastic/inputs/base/errors.rb +4 -3
  47. data/lib/formtastic/inputs/base/fileish.rb +1 -0
  48. data/lib/formtastic/inputs/base/hints.rb +1 -0
  49. data/lib/formtastic/inputs/base/html.rb +3 -2
  50. data/lib/formtastic/inputs/base/labelling.rb +4 -3
  51. data/lib/formtastic/inputs/base/naming.rb +1 -0
  52. data/lib/formtastic/inputs/base/numeric.rb +1 -0
  53. data/lib/formtastic/inputs/base/options.rb +1 -0
  54. data/lib/formtastic/inputs/base/placeholder.rb +1 -0
  55. data/lib/formtastic/inputs/base/stringish.rb +1 -0
  56. data/lib/formtastic/inputs/base/timeish.rb +4 -3
  57. data/lib/formtastic/inputs/base/validations.rb +33 -8
  58. data/lib/formtastic/inputs/base/wrapping.rb +1 -0
  59. data/lib/formtastic/inputs/base.rb +5 -2
  60. data/lib/formtastic/inputs/boolean_input.rb +2 -1
  61. data/lib/formtastic/inputs/check_boxes_input.rb +2 -1
  62. data/lib/formtastic/inputs/color_input.rb +1 -0
  63. data/lib/formtastic/inputs/country_input.rb +10 -6
  64. data/lib/formtastic/inputs/datalist_input.rb +1 -0
  65. data/lib/formtastic/inputs/date_picker_input.rb +1 -0
  66. data/lib/formtastic/inputs/date_select_input.rb +1 -0
  67. data/lib/formtastic/inputs/datetime_picker_input.rb +1 -0
  68. data/lib/formtastic/inputs/datetime_select_input.rb +1 -0
  69. data/lib/formtastic/inputs/email_input.rb +1 -0
  70. data/lib/formtastic/inputs/file_input.rb +1 -0
  71. data/lib/formtastic/inputs/hidden_input.rb +3 -2
  72. data/lib/formtastic/inputs/number_input.rb +1 -0
  73. data/lib/formtastic/inputs/password_input.rb +1 -0
  74. data/lib/formtastic/inputs/phone_input.rb +1 -0
  75. data/lib/formtastic/inputs/radio_input.rb +1 -0
  76. data/lib/formtastic/inputs/range_input.rb +1 -0
  77. data/lib/formtastic/inputs/search_input.rb +1 -0
  78. data/lib/formtastic/inputs/select_input.rb +1 -0
  79. data/lib/formtastic/inputs/string_input.rb +1 -0
  80. data/lib/formtastic/inputs/text_input.rb +1 -0
  81. data/lib/formtastic/inputs/time_picker_input.rb +1 -0
  82. data/lib/formtastic/inputs/time_select_input.rb +1 -0
  83. data/lib/formtastic/inputs/time_zone_input.rb +1 -0
  84. data/lib/formtastic/inputs/url_input.rb +1 -0
  85. data/lib/formtastic/inputs.rb +1 -0
  86. data/lib/formtastic/localized_string.rb +1 -0
  87. data/lib/formtastic/localizer.rb +1 -0
  88. data/lib/formtastic/namespaced_class_finder.rb +7 -8
  89. data/lib/formtastic/version.rb +2 -1
  90. data/lib/formtastic.rb +7 -2
  91. data/lib/generators/formtastic/form/form_generator.rb +3 -3
  92. data/lib/generators/formtastic/input/input_generator.rb +1 -0
  93. data/lib/generators/formtastic/install/install_generator.rb +1 -1
  94. data/lib/generators/formtastic/stylesheets/stylesheets_generator.rb +15 -0
  95. data/{app/assets/stylesheets → lib/generators/templates}/formtastic.css +4 -4
  96. data/lib/generators/templates/formtastic.rb +8 -1
  97. data/script/integration-template.rb +16 -14
  98. data/script/integration.sh +17 -4
  99. data/spec/action_class_finder_spec.rb +1 -1
  100. data/spec/actions/button_action_spec.rb +17 -17
  101. data/spec/actions/generic_action_spec.rb +130 -130
  102. data/spec/actions/input_action_spec.rb +16 -16
  103. data/spec/actions/link_action_spec.rb +25 -25
  104. data/spec/builder/custom_builder_spec.rb +5 -5
  105. data/spec/builder/error_proc_spec.rb +2 -2
  106. data/spec/builder/semantic_fields_for_spec.rb +97 -26
  107. data/spec/fast_spec_helper.rb +1 -1
  108. data/spec/generators/formtastic/form/form_generator_spec.rb +8 -7
  109. data/spec/generators/formtastic/input/input_generator_spec.rb +1 -0
  110. data/spec/generators/formtastic/install/install_generator_spec.rb +1 -0
  111. data/spec/generators/formtastic/stylesheets/stylesheets_generator_spec.rb +22 -0
  112. data/spec/helpers/action_helper_spec.rb +15 -14
  113. data/spec/helpers/actions_helper_spec.rb +42 -42
  114. data/spec/helpers/form_helper_spec.rb +26 -20
  115. data/spec/helpers/input_helper_spec.rb +82 -70
  116. data/spec/helpers/inputs_helper_spec.rb +179 -180
  117. data/spec/helpers/reflection_helper_spec.rb +4 -4
  118. data/spec/helpers/semantic_errors_helper_spec.rb +118 -10
  119. data/spec/i18n_spec.rb +13 -13
  120. data/spec/input_class_finder_spec.rb +1 -1
  121. data/spec/inputs/base/collections_spec.rb +43 -0
  122. data/spec/inputs/base/validations_spec.rb +1 -0
  123. data/spec/inputs/boolean_input_spec.rb +66 -66
  124. data/spec/inputs/check_boxes_input_spec.rb +89 -89
  125. data/spec/inputs/color_input_spec.rb +7 -7
  126. data/spec/inputs/country_input_spec.rb +15 -15
  127. data/spec/inputs/custom_input_spec.rb +1 -1
  128. data/spec/inputs/datalist_input_spec.rb +2 -2
  129. data/spec/inputs/date_picker_input_spec.rb +109 -109
  130. data/spec/inputs/date_select_input_spec.rb +63 -63
  131. data/spec/inputs/datetime_picker_input_spec.rb +118 -118
  132. data/spec/inputs/datetime_select_input_spec.rb +72 -72
  133. data/spec/inputs/email_input_spec.rb +16 -16
  134. data/spec/inputs/file_input_spec.rb +17 -17
  135. data/spec/inputs/hidden_input_spec.rb +29 -29
  136. data/spec/inputs/include_blank_spec.rb +7 -7
  137. data/spec/inputs/label_spec.rb +57 -25
  138. data/spec/inputs/number_input_spec.rb +159 -159
  139. data/spec/inputs/password_input_spec.rb +17 -17
  140. data/spec/inputs/phone_input_spec.rb +16 -16
  141. data/spec/inputs/placeholder_spec.rb +17 -17
  142. data/spec/inputs/radio_input_spec.rb +58 -58
  143. data/spec/inputs/range_input_spec.rb +108 -108
  144. data/spec/inputs/readonly_spec.rb +5 -5
  145. data/spec/inputs/search_input_spec.rb +15 -15
  146. data/spec/inputs/select_input_spec.rb +144 -94
  147. data/spec/inputs/string_input_spec.rb +103 -37
  148. data/spec/inputs/text_input_spec.rb +32 -32
  149. data/spec/inputs/time_picker_input_spec.rb +110 -110
  150. data/spec/inputs/time_select_input_spec.rb +71 -71
  151. data/spec/inputs/time_zone_input_spec.rb +21 -21
  152. data/spec/inputs/url_input_spec.rb +16 -16
  153. data/spec/inputs/with_options_spec.rb +8 -8
  154. data/spec/localizer_spec.rb +1 -1
  155. data/spec/namespaced_class_finder_spec.rb +17 -6
  156. data/spec/schema.rb +1 -0
  157. data/spec/spec_helper.rb +10 -9
  158. data/spec/support/custom_macros.rb +75 -66
  159. data/spec/support/deprecation.rb +2 -1
  160. data/spec/support/shared_examples.rb +2 -1
  161. data/spec/support/specialized_class_finder_shared_example.rb +1 -1
  162. data/spec/support/test_environment.rb +2 -1
  163. metadata +65 -37
  164. data/Gemfile.lock +0 -105
  165. data/app/assets/stylesheets/formtastic_ie6.css +0 -33
  166. data/app/assets/stylesheets/formtastic_ie7.css +0 -23
  167. data/gemfiles/rails_5.2/Gemfile +0 -5
  168. data/gemfiles/rails_6.0/Gemfile +0 -5
  169. data/gemfiles/rails_6.1/Gemfile +0 -5
  170. data/gemfiles/rails_edge/Gemfile +0 -13
  171. data/lib/formtastic/engine.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb44ea01df970135604cdddd0ac7b762ea56077f915810c4c8fe6be3487cafa3
4
- data.tar.gz: 18630a8282b76e40d0c6e9faad19f99112dfd9e22ba22e7b025d8730ebf26ace
3
+ metadata.gz: 211d0d0b33c1ea9fbd35858a71924740a27dd0a39b4e0e0cc48f16e7753388b1
4
+ data.tar.gz: 102435b082e7b83ddcfd874d8fe89f016b622e7f48fea56de0f8a136e162e072
5
5
  SHA512:
6
- metadata.gz: 73a3ad17e91765150e4e15e03d3031f5b9efd975a09bbb21c7f404709b7d2462e9cf16c708beaf2745b783def3a631ca1b3bd47278d79c16012d79ba1f549fc0
7
- data.tar.gz: d418a7e65f928dedfd36627c3ece7c4fe7e371984500ddc4bcb6c5929087264541476c469be6520270000a0e8348bc2cd41415e94d46c86da2e48021bf54d4be
6
+ metadata.gz: 454ed223f77ba1aa04c722e08fde0cf6494343e95f871611bc57275f335cd1cae26933b4ca45505abb58f4cfba539a9ffd0ec9888c55a7cd7a1d2badcbecf7c0
7
+ data.tar.gz: af525b290f06a4bb5753842a52ea6f7ff439b6496a8e435d1fa23ca9d3c2edcbcbc74eb8e44f46adeb7eb608f2fa3ffbcde6b0dfb8919b58dd37b39ab6407349
@@ -0,0 +1,36 @@
1
+ name: integration
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ ci:
11
+ runs-on: ubuntu-latest
12
+ needs: test
13
+ steps:
14
+ - uses: actions/checkout@v6
15
+ test:
16
+ runs-on: ubuntu-22.04
17
+
18
+ strategy:
19
+ fail-fast: false
20
+
21
+ steps:
22
+ - uses: actions/checkout@v6
23
+
24
+ - uses: actions/setup-node@v6
25
+ with:
26
+ node-version: 11
27
+
28
+ - name: Set up Ruby
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: '4.0'
32
+ bundler-cache: true
33
+ bundler: latest
34
+
35
+ - name: Run integration
36
+ run: script/integration.sh
@@ -2,49 +2,55 @@ name: test
2
2
 
3
3
  on:
4
4
  push:
5
+ branches:
6
+ - main
5
7
  pull_request:
6
8
 
7
9
  jobs:
10
+ ci:
11
+ runs-on: ubuntu-latest
12
+ needs: test
13
+ steps:
14
+ - uses: actions/checkout@v6
8
15
  test:
9
- runs-on: ubuntu-20.04
16
+ runs-on: ubuntu-22.04
10
17
 
11
18
  strategy:
12
19
  fail-fast: false
13
20
 
14
21
  matrix:
15
22
  gemfile:
16
- - gemfiles/rails_5.2/Gemfile
17
- - gemfiles/rails_6.0/Gemfile
18
- - gemfiles/rails_6.1/Gemfile
19
- - gemfiles/rails_edge/Gemfile
23
+ - gemfiles/rails_72.gemfile
24
+ - gemfiles/rails_80.gemfile
25
+ - gemfiles/rails_81.gemfile
26
+ - gemfiles/rails_edge.gemfile
20
27
 
21
28
  ruby:
22
- - 2.4.10
23
- - 2.5.8
24
- - 2.6.6
25
- - 2.7.2
26
- - 3.0.0
29
+ - '3.1'
30
+ - '3.2'
31
+ - '3.3'
32
+ - '3.4'
33
+ - '4.0'
27
34
 
28
35
  exclude:
29
- - ruby: 2.4.10
30
- gemfile: gemfiles/rails_6.0/Gemfile
31
-
32
- - ruby: 2.4.10
33
- gemfile: gemfiles/rails_6.1/Gemfile
34
-
35
- - ruby: 2.4.10
36
- gemfile: gemfiles/rails_edge/Gemfile
37
-
38
- - ruby: 3.0.0
39
- gemfile: gemfiles/rails_5.2/Gemfile
36
+ - gemfile: gemfiles/rails_80.gemfile
37
+ ruby: '3.1'
38
+ - gemfile: gemfiles/rails_81.gemfile
39
+ ruby: '3.1'
40
+ - gemfile: gemfiles/rails_edge.gemfile
41
+ ruby: '3.1'
42
+ - gemfile: gemfiles/rails_edge.gemfile
43
+ ruby: '3.2'
44
+ - gemfile: gemfiles/rails_72.gemfile
45
+ ruby: '4.0'
40
46
 
41
47
  env:
42
48
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
43
49
 
44
50
  steps:
45
- - uses: actions/checkout@v2
51
+ - uses: actions/checkout@v6
46
52
 
47
- - uses: actions/setup-node@v2
53
+ - uses: actions/setup-node@v6
48
54
  with:
49
55
  node-version: 11
50
56
 
@@ -53,9 +59,9 @@ jobs:
53
59
  with:
54
60
  ruby-version: ${{ matrix.ruby }}
55
61
  bundler-cache: true
62
+ bundler: latest
56
63
 
57
64
  - name: Run tests
58
65
  run: |
59
66
  bundle exec rake spec
60
- script/integration.sh
61
- continue-on-error: ${{ matrix.gemfile == 'gemfiles/rails_edge/Gemfile' }}
67
+ continue-on-error: ${{ matrix.gemfile == 'gemfiles/rails_edge.gemfile' }}
data/.gitignore CHANGED
@@ -14,5 +14,6 @@ log/*
14
14
  .yardoc
15
15
  doc/
16
16
  tmp
17
- gemfiles/*/Gemfile.lock
17
+ Gemfile.lock
18
+ gemfiles/*.gemfile.lock
18
19
  /dummy/
data/Appraisals ADDED
@@ -0,0 +1,23 @@
1
+ appraise "rails-72" do
2
+ gem "actionpack", "~> 7.2.3"
3
+ gem "activesupport", "~> 7.2.3"
4
+ gem "activerecord", "~> 7.2.3"
5
+ end
6
+
7
+ appraise "rails-80" do
8
+ gem "actionpack", "~> 8.0.4"
9
+ gem "activesupport", "~> 8.0.4"
10
+ gem "activerecord", "~> 8.0.4"
11
+ end
12
+
13
+ appraise "rails-81" do
14
+ gem "actionpack", "~> 8.1.2"
15
+ gem "activesupport", "~> 8.1.2"
16
+ gem "activerecord", "~> 8.1.2"
17
+ end
18
+
19
+ appraise "rails-edge" do
20
+ gem "actionpack", git: "https://github.com/rails/rails.git", branch: "main"
21
+ gem "activesupport", git: "https://github.com/rails/rails.git", branch: "main"
22
+ gem "activerecord", git: "https://github.com/rails/rails.git", branch: "main"
23
+ end
data/CHANGELOG.md CHANGED
@@ -1,4 +1,31 @@
1
- ## master / 4.0.0
1
+ ## 6.0.0.alpha
2
+
3
+ * Removed support for Rails 6.0 & 7.1 (min version is now 7.2)
4
+ * Removed support for Ruby < 3.1 in line with Rails 7.2
5
+ * Added requirement for minimum Ruby Gems version in line with Rails 7.2
6
+ * Added formtastic:stylesheets generator (does not include legacy IE stylesheets)
7
+ * Removed formtastic engine stylesheets
8
+ * Added `semantic_errors_link_to_inputs` config option to improve accessibility of `semantic_errors`. ([#1388](https://github.com/formtastic/formtastic/pull/1388))
9
+ * Fixed country_select compatibility by switching from v1 to v2 syntax ([#1382](https://github.com/formtastic/formtastic/pull/1382))
10
+ * Fixed that passing caller to Deprecation#warn is deprecated ([#1384](https://github.com/formtastic/formtastic/pull/1384))
11
+ * Added `label_html` option for overriding & adding label HTML attributes ([#1379](https://github.com/formtastic/formtastic/pull/1379))
12
+ * Added better support for collections of Symbols ([#1391](https://github.com/formtastic/formtastic/pull/1391))
13
+ * Fixed issue with inferred max length for integer columns
14
+ * Fixed issue with Prox length validations ([#1405](https://github.com/formtastic/formtastic/pull/1405))
15
+ * Various minor Ruby, Rails, documentation and maintenance activities
16
+
17
+ ## 5.0.0
18
+
19
+ * Added support for Rails 7.1 ([#1371](https://github.com/formtastic/formtastic/pull/1371))
20
+ * Removed support for Rails < 6.0.0 ([#1354](https://github.com/formtastic/formtastic/pull/1354))
21
+ * Removed support for Rubies < 2.6.0 ([#1332](https://github.com/formtastic/formtastic/pull/1332), [#1355](https://github.com/formtastic/formtastic.git/pull/1355))
22
+ * Added support for scopes in relations ([#1343](https://github.com/formtastic/formtastic/pull/1343))
23
+ * Fixed I18n lookup for enum values in nested select fields ([#1342](https://github.com/formtastic/formtastic/pull/1342))
24
+ * Fixed faster input class lookup ([#1336](https://github.com/formtastic/formtastic/pull/1336))
25
+ * Use frozen_string_literal internally ([#1339](https://github.com/formtastic/formtastic/pull/1339))
26
+
27
+ ## 4.0.0
28
+
2
29
  * Fixed default_columns_for_object when object has non-standard foreign keys (#1241)
3
30
  * Fixed missing constants in production (#911)
4
31
  * Removed support for Rails 3 and 4.0 (#1108)
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,27 @@
1
+ # Contributing
2
+
3
+ ## General Workflow
4
+
5
+ * Fork the project on Github
6
+ * Install development dependencies (`bundle install` and `bundle exec rake appraisal:install`)
7
+ * Run the appraisals to check you've got a clean build with passing tests to work on (`bundle exec rake`)
8
+ * Create a topic branch for your changes
9
+ * Ensure that you provide *documentation* and *test coverage* for your changes (patches won't be accepted without)
10
+ * Ensure that all tests still pass (`bundle exec rake`)
11
+ * Create a pull request on Github (these are also a great place to start a conversation around a WIP patch as early as possible)
12
+
13
+
14
+ ## Continuos Integration
15
+
16
+ Formtastic supports multiple versions of Rails and Ruby. Here's the approach to managing the complexity:
17
+
18
+ * The gemspec has a `required_ruby_version` that matches the minimum Ruby version supported by the minimum Rails version we currently support.
19
+ * The gemspec has a dependency on `actionpack` matching the minimum Rails version we currently support.
20
+ * The gemspec has several development dependencies, but we're not specific about which version. That complexity is handled by Appraisals and/or bundler.
21
+ * There is an Appraisal for each of the Rails versions we currently test with (eg Rails 7, 8 and edge) that can name specific versions of these dependencies and developer dependencies as needed.
22
+ * Use `bundle exec appraisal` to generate new `gemfiles/*` as needed. We do not check-in the `*.gemfile.lock`, so that each Ruby version in the CI matrix can select an appropriate version of each dependency.
23
+ * The GitHub `test.yml` workflow runs a matrix of builds agqainst multiple Ruby and Rails versions, excluding any that don't make sense based on the minimum Ruby version for certain Rails versions.
24
+
25
+
26
+
27
+
data/Gemfile CHANGED
@@ -1,3 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ # Which version of Rails to use specifically for local development. These currently match rails_8.gemfile.
4
+ gem "actionpack", "~> 8.0.2"
5
+ gem "activesupport", "~> 8.0.2"
6
+ gem "activerecord", "~> 8.0.2"
7
+
3
8
  gemspec
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008-2021
1
+ Copyright (c) 2007-2025
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
data/README.md CHANGED
@@ -9,16 +9,15 @@ Formtastic is a Rails FormBuilder DSL (with some other goodies) to make it far e
9
9
 
10
10
  ## Documentation & Support
11
11
 
12
- * [Documentation is available on rdoc.info](https://rdoc.info/projects/formtastic/formtastic)
12
+ * [Documentation is available on rubydoc.info](https://rubydoc.info/github/formtastic/formtastic)
13
13
  * [We track issues & bugs on GitHub](https://github.com/formtastic/formtastic/issues)
14
14
  * [We have a wiki on GitHub](https://github.com/formtastic/formtastic/wiki)
15
15
  * [StackOverflow can help](https://stackoverflow.com/questions/tagged/formtastic)
16
16
 
17
17
  ## Compatibility
18
18
 
19
- * Formtastic 4 requires Rails 5.2 and Ruby 2.5 minimum
20
- * Formtastic 3 requires Rails 3.2.13 minimum
21
- * Formtastic 2 requires Rails 3
19
+ * Formtastic 5.0 (current release) requires Rails 6.0 and Ruby 2.6 minimum
20
+ * Formtastic 6.0 / edge requires Rails 7.2 and Ruby 3.1 minimum, inline with Rails minimum supported versions
22
21
  * Formtastic, much like Rails, is very ActiveRecord-centric. Many are successfully using other ActiveModel-like ORMs and objects (DataMapper, MongoMapper, Mongoid, Authlogic, Devise...) but we're not guaranteeing full compatibility at this stage. Patches are welcome!
23
22
 
24
23
  ## The Story
@@ -88,7 +87,7 @@ I also wrote the accompanying HTML output I expected, favoring something very si
88
87
  Simply add Formtastic to your Gemfile and bundle it up:
89
88
 
90
89
  ```ruby
91
- gem 'formtastic', '~> 4.0'
90
+ gem 'formtastic', '~> 5.0'
92
91
  ```
93
92
 
94
93
  Run the installation generator:
@@ -100,37 +99,12 @@ $ rails generate formtastic:install
100
99
 
101
100
  ## Stylesheets
102
101
 
103
- A proof-of-concept set of stylesheets are provided which you can include in your layout. Customization is best achieved by overriding these styles in an additional stylesheet.
102
+ An optional proof-of-concept stylesheet can be generated and installed into your app:
104
103
 
105
- Rails 3.1 introduces an asset pipeline that allows plugins like Formtastic to serve their own Stylesheets, Javascripts, etc without having to run generators that copy them across to the host application. Formtastic makes three stylesheets available as an Engine, you just need to require them in your global stylesheets.
106
-
107
- ```css
108
- # app/assets/stylesheets/application.css
109
- *= require formtastic
110
- *= require my_formtastic_changes
111
- ```
112
-
113
- Conditional stylesheets need to be compiled separately to prevent them being bundled and included with other application styles. Remove `require_tree .` from application.css and specify required stylesheets individually.
114
-
115
- ```css
116
- # app/assets/stylesheets/ie6.css
117
- *= require formtastic_ie6
118
-
119
- # app/assets/stylesheets/ie7.css
120
- *= require formtastic_ie7
121
- ```
122
-
123
- ```erb
124
- # app/views/layouts/application.html.erb
125
- <%= stylesheet_link_tag 'application' %>
126
- <!--[if IE 6]><%= stylesheet_link_tag 'ie6' %><![endif]-->
127
- <!--[if IE 7]><%= stylesheet_link_tag 'ie7' %><![endif]-->
104
+ ```shell
105
+ $ rails generate formtastic:stylesheet
128
106
  ```
129
107
 
130
- ```ruby
131
- # config/environments/production.rb
132
- config.assets.precompile += %w( ie6.css ie7.css )
133
- ```
134
108
 
135
109
  ## Usage
136
110
 
@@ -570,6 +544,10 @@ To create your own new types of inputs based on existing inputs, the process is
570
544
  def input_html_options
571
545
  super.merge(:class => "flexible-text-area")
572
546
  end
547
+
548
+ def options
549
+ super.merge(hint: 'This is a flexible text area')
550
+ end
573
551
  end
574
552
  ```
575
553
 
@@ -603,18 +581,13 @@ You can use your new input with `:as => :date_picker`.
603
581
 
604
582
  There are none other than Rails itself, but...
605
583
 
606
- * If you want to use the `:country` input, you'll need to install the [country-select plugin](https://github.com/stefanpenner/country_select) (or any other country_select plugin with the same API). Both 1.x and 2.x are supported, but they behave differently when storing data, so please see their [upgrade notes](https://github.com/stefanpenner/country_select/blob/master/UPGRADING.md) if switching from 1.x.
584
+ * If you want to use the `:country` input, you'll need to install the [country-select plugin](https://github.com/countries/country_select) (or any other country_select plugin with the same API).
607
585
  * There are a bunch of development dependencies if you plan to contribute to Formtastic
608
586
 
609
587
 
610
588
  ## How to contribute
611
589
 
612
- * Fork the project on Github
613
- * Install development dependencies (`bundle install` and `bin/appraisal install`)
614
- * Create a topic branch for your changes
615
- * Ensure that you provide *documentation* and *test coverage* for your changes (patches won't be accepted without)
616
- * Ensure that all tests pass (`bundle exec rake`)
617
- * Create a pull request on Github (these are also a great place to start a conversation around a patch as early as possible)
590
+ See `CONTRIBUTING.md`
618
591
 
619
592
 
620
593
  ## Project Info
@@ -623,5 +596,5 @@ Formtastic was created by [Justin French](https://www.justinfrench.com) with con
623
596
 
624
597
  The project is hosted on Github: [https://github.com/formtastic/formtastic](https://github.com/formtastic/formtastic), where your contributions, forkings, comments, issues and feedback are greatly welcomed.
625
598
 
626
- Copyright (c) 2007-2021, released under the MIT license.
599
+ Copyright (c) 2007-2025, released under the MIT license.
627
600
 
data/Rakefile CHANGED
@@ -25,7 +25,7 @@ namespace :appraisal do
25
25
  end
26
26
 
27
27
  def for_all_gemfiles(*args)
28
- Dir.glob("gemfiles/*/Gemfile").sort.each do |gemfile|
28
+ Dir.glob("gemfiles/*.gemfile").sort.each do |gemfile|
29
29
  Bundler.with_original_env do
30
30
  sh({ "APPRAISAL_INITIALIZED" => "true", "BUNDLE_GEMFILE" => gemfile }, "bundle", *args)
31
31
  end
data/formtastic.gemspec CHANGED
@@ -21,16 +21,25 @@ Gem::Specification.new do |s|
21
21
  s.rdoc_options = ["--charset=UTF-8"]
22
22
  s.extra_rdoc_files = ["README.md"]
23
23
 
24
- s.required_ruby_version = '>= 2.4.0'
25
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
26
- s.rubygems_version = %q{1.3.6}
24
+ # Minimum Ruby version is probably the same as whatever the minimum Rails version currently expects.
25
+ s.required_ruby_version = '>= 3.1.0'
27
26
 
28
- s.add_dependency(%q<actionpack>, [">= 5.2.0"])
27
+ # Minimum Ruby Gems version also matches whatever the minimum Rails version currently expects.
28
+ s.required_rubygems_version = ">= 1.8.11"
29
29
 
30
- s.add_development_dependency(%q<rspec-rails>, ["~> 3.4"])
31
- s.add_development_dependency(%q<rspec-dom-testing>, [">= 0.1.0"])
32
- s.add_development_dependency(%q<yard>, ["~> 0.9.20"])
33
- s.add_development_dependency(%q<ammeter>, ["~> 1.1.3"])
30
+ # User dependency is really just Rails, where we want describe the minimum version we support,
31
+ # which is probably the oldest version that hasn't reached end-of-life for security updates.
32
+ s.add_dependency(%q<actionpack>, [">= 7.2.0"])
33
+
34
+ # Development dependencies (for people working on Formtastic) are different to the minimum support
35
+ # version. Instead of specifying a specific version of each, we just specify the stack, and let the
36
+ # details of which versions work with each version of rails be managed in the Appraisal.
37
+ s.add_development_dependency(%q<appraisal>)
38
+ s.add_development_dependency(%q<rspec-rails>)
39
+ s.add_development_dependency(%q<rspec-dom-testing>)
40
+ s.add_development_dependency(%q<rspec-mocks>)
41
+ s.add_development_dependency(%q<yard>)
42
+ s.add_development_dependency(%q<ammeter>)
34
43
  s.add_development_dependency(%q<rake>)
35
- s.add_development_dependency(%q<sqlite3>, ["~> 1.4"])
44
+ s.add_development_dependency(%q<sqlite3>)
36
45
  end
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "actionpack", "~> 7.2.3"
6
+ gem "activesupport", "~> 7.2.3"
7
+ gem "activerecord", "~> 7.2.3"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "actionpack", "~> 8.0.4"
6
+ gem "activesupport", "~> 8.0.4"
7
+ gem "activerecord", "~> 8.0.4"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "actionpack", "~> 8.1.2"
6
+ gem "activesupport", "~> 8.1.2"
7
+ gem "activerecord", "~> 8.1.2"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "actionpack", git: "https://github.com/rails/rails.git", branch: "main"
6
+ gem "activesupport", git: "https://github.com/rails/rails.git", branch: "main"
7
+ gem "activerecord", git: "https://github.com/rails/rails.git", branch: "main"
8
+
9
+ gemspec path: "../"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Formtastic
2
3
 
3
4
  # Uses the {NamespacedClassFinder} to look up action class names.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Formtastic
2
3
  module Actions
3
4
  module Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Formtastic
2
3
  module Actions
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Formtastic
2
3
  module Actions
3
4
  module Buttonish
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Formtastic
2
3
  module Actions
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Formtastic
2
3
  module Actions
3
4
  # Outputs a link wrapped in the standard `<li>` wrapper. This the default for `:cancel` actions.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Formtastic
2
3
  module Actions
3
4
  extend ActiveSupport::Autoload
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  require 'active_support/deprecation'
2
3
 
3
4
  module Formtastic
4
- Deprecation = ActiveSupport::Deprecation
5
+ Deprecation = ActiveSupport::Deprecation.new("5.0.0", "Formtastic")
5
6
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Formtastic
2
3
  class FormBuilder < ActionView::Helpers::FormBuilder
3
4
 
@@ -15,40 +16,40 @@ module Formtastic
15
16
  self.send(:"#{name}=", default)
16
17
  end
17
18
 
18
- configure :custom_namespace
19
- configure :default_text_field_size
20
- configure :default_text_area_height, 20
21
- configure :default_text_area_width
19
+ # Check {Formtastic::ActionClassFinder} to see how are inputs resolved.
20
+ configure :action_class_finder, Formtastic::ActionClassFinder
21
+ configure :action_namespaces, [::Object, ::Formtastic::Actions]
22
22
  configure :all_fields_required_by_default, true
23
- configure :include_blank_for_select_by_default, true
24
- configure :required_string, proc { %{<abbr title="#{Formtastic::I18n.t(:required)}">*</abbr>}.html_safe }
25
- configure :optional_string, ''
26
- configure :inline_errors, :sentence
27
- configure :label_str_method, :humanize
28
23
  configure :collection_label_methods, %w[to_label display_name full_name name title username login value to_s]
29
24
  configure :collection_value_methods, %w[id to_s]
30
- configure :file_methods, [ :file?, :public_filename, :filename ]
31
- configure :file_metadata_suffixes, ['content_type', 'file_name', 'file_size']
32
- configure :priority_countries, ["Australia", "Canada", "United Kingdom", "United States"]
33
- configure :i18n_lookups_by_default, true
34
- configure :i18n_cache_lookups, true
35
- configure :i18n_localizer, Formtastic::Localizer
36
- configure :escape_html_entities_in_hints_and_labels, true
25
+ configure :custom_namespace
37
26
  configure :default_commit_button_accesskey
38
- configure :default_inline_error_class, 'inline-errors'
39
27
  configure :default_error_list_class, 'errors'
40
28
  configure :default_hint_class, 'inline-hints'
41
- configure :use_required_attribute, false
42
- configure :perform_browser_validations, false
29
+ configure :default_inline_error_class, 'inline-errors'
30
+ configure :default_text_area_height, 20
31
+ configure :default_text_area_width
32
+ configure :default_text_field_size
33
+ configure :escape_html_entities_in_hints_and_labels, true
34
+ configure :file_metadata_suffixes, ['content_type', 'file_name', 'file_size']
35
+ configure :file_methods, [ :file?, :public_filename, :filename ]
36
+ configure :i18n_cache_lookups, true
37
+ configure :i18n_localizer, Formtastic::Localizer
38
+ configure :i18n_lookups_by_default, true
39
+ configure :include_blank_for_select_by_default, true
40
+ configure :inline_errors, :sentence
43
41
  # Check {Formtastic::InputClassFinder} to see how are inputs resolved.
44
- configure :input_namespaces, [::Object, ::Formtastic::Inputs]
45
42
  configure :input_class_finder, Formtastic::InputClassFinder
46
- # Check {Formtastic::ActionClassFinder} to see how are inputs resolved.
47
- configure :action_namespaces, [::Object, ::Formtastic::Actions]
48
- configure :action_class_finder, Formtastic::ActionClassFinder
49
-
50
- configure :skipped_columns, [:created_at, :updated_at, :created_on, :updated_on, :lock_version, :version]
43
+ configure :input_namespaces, [::Object, ::Formtastic::Inputs]
44
+ configure :label_str_method, :humanize
45
+ configure :optional_string, ''
46
+ configure :perform_browser_validations, false
47
+ configure :priority_countries, ["Australia", "Canada", "United Kingdom", "United States"]
51
48
  configure :priority_time_zones, []
49
+ configure :required_string, proc { %{<abbr title="#{Formtastic::I18n.t(:required)}">*</abbr>}.html_safe }
50
+ configure :semantic_errors_link_to_inputs, false
51
+ configure :skipped_columns, [:created_at, :updated_at, :created_on, :updated_on, :lock_version, :version]
52
+ configure :use_required_attribute, false
52
53
 
53
54
  attr_reader :template
54
55
 
@@ -1,4 +1,4 @@
1
- # -*- coding: utf-8 -*-
1
+ # frozen_string_literal: true
2
2
  module Formtastic
3
3
  module Helpers
4
4
  module ActionHelper
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Formtastic
2
3
  module Helpers
3
4
  # ActionsHelper encapsulates the responsibilties of the {#actions} DSL for acting on
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Formtastic
2
3
  module Helpers
3
4
  # @private