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.
- checksums.yaml +4 -4
- data/.github/workflows/integration.yaml +36 -0
- data/.github/workflows/test.yml +31 -25
- data/.gitignore +2 -1
- data/Appraisals +23 -0
- data/CHANGELOG.md +28 -1
- data/CONTRIBUTING.md +27 -0
- data/Gemfile +5 -0
- data/MIT-LICENSE +1 -1
- data/README.md +14 -41
- data/Rakefile +1 -1
- data/formtastic.gemspec +18 -9
- data/gemfiles/rails_72.gemfile +9 -0
- data/gemfiles/rails_80.gemfile +9 -0
- data/gemfiles/rails_81.gemfile +9 -0
- data/gemfiles/rails_edge.gemfile +9 -0
- data/lib/formtastic/action_class_finder.rb +1 -0
- data/lib/formtastic/actions/base.rb +1 -0
- data/lib/formtastic/actions/button_action.rb +1 -0
- data/lib/formtastic/actions/buttonish.rb +1 -0
- data/lib/formtastic/actions/input_action.rb +1 -0
- data/lib/formtastic/actions/link_action.rb +1 -0
- data/lib/formtastic/actions.rb +1 -0
- data/lib/formtastic/deprecation.rb +2 -1
- data/lib/formtastic/form_builder.rb +26 -25
- data/lib/formtastic/helpers/action_helper.rb +1 -1
- data/lib/formtastic/helpers/actions_helper.rb +1 -0
- data/lib/formtastic/helpers/enum.rb +1 -0
- data/lib/formtastic/helpers/errors_helper.rb +72 -14
- data/lib/formtastic/helpers/fieldset_wrapper.rb +1 -0
- data/lib/formtastic/helpers/file_column_detection.rb +1 -0
- data/lib/formtastic/helpers/form_helper.rb +1 -0
- data/lib/formtastic/helpers/input_helper.rb +6 -6
- data/lib/formtastic/helpers/inputs_helper.rb +2 -1
- data/lib/formtastic/helpers/reflection.rb +1 -0
- data/lib/formtastic/helpers.rb +1 -1
- data/lib/formtastic/html_attributes.rb +1 -0
- data/lib/formtastic/i18n.rb +1 -1
- data/lib/formtastic/input_class_finder.rb +1 -0
- data/lib/formtastic/inputs/base/aria.rb +26 -0
- data/lib/formtastic/inputs/base/associations.rb +1 -0
- data/lib/formtastic/inputs/base/choices.rb +2 -1
- data/lib/formtastic/inputs/base/collections.rb +5 -2
- data/lib/formtastic/inputs/base/database.rb +5 -7
- data/lib/formtastic/inputs/base/datetime_pickerish.rb +1 -0
- data/lib/formtastic/inputs/base/errors.rb +4 -3
- data/lib/formtastic/inputs/base/fileish.rb +1 -0
- data/lib/formtastic/inputs/base/hints.rb +1 -0
- data/lib/formtastic/inputs/base/html.rb +3 -2
- data/lib/formtastic/inputs/base/labelling.rb +4 -3
- data/lib/formtastic/inputs/base/naming.rb +1 -0
- data/lib/formtastic/inputs/base/numeric.rb +1 -0
- data/lib/formtastic/inputs/base/options.rb +1 -0
- data/lib/formtastic/inputs/base/placeholder.rb +1 -0
- data/lib/formtastic/inputs/base/stringish.rb +1 -0
- data/lib/formtastic/inputs/base/timeish.rb +4 -3
- data/lib/formtastic/inputs/base/validations.rb +33 -8
- data/lib/formtastic/inputs/base/wrapping.rb +1 -0
- data/lib/formtastic/inputs/base.rb +5 -2
- data/lib/formtastic/inputs/boolean_input.rb +2 -1
- data/lib/formtastic/inputs/check_boxes_input.rb +2 -1
- data/lib/formtastic/inputs/color_input.rb +1 -0
- data/lib/formtastic/inputs/country_input.rb +10 -6
- data/lib/formtastic/inputs/datalist_input.rb +1 -0
- data/lib/formtastic/inputs/date_picker_input.rb +1 -0
- data/lib/formtastic/inputs/date_select_input.rb +1 -0
- data/lib/formtastic/inputs/datetime_picker_input.rb +1 -0
- data/lib/formtastic/inputs/datetime_select_input.rb +1 -0
- data/lib/formtastic/inputs/email_input.rb +1 -0
- data/lib/formtastic/inputs/file_input.rb +1 -0
- data/lib/formtastic/inputs/hidden_input.rb +3 -2
- data/lib/formtastic/inputs/number_input.rb +1 -0
- data/lib/formtastic/inputs/password_input.rb +1 -0
- data/lib/formtastic/inputs/phone_input.rb +1 -0
- data/lib/formtastic/inputs/radio_input.rb +1 -0
- data/lib/formtastic/inputs/range_input.rb +1 -0
- data/lib/formtastic/inputs/search_input.rb +1 -0
- data/lib/formtastic/inputs/select_input.rb +1 -0
- data/lib/formtastic/inputs/string_input.rb +1 -0
- data/lib/formtastic/inputs/text_input.rb +1 -0
- data/lib/formtastic/inputs/time_picker_input.rb +1 -0
- data/lib/formtastic/inputs/time_select_input.rb +1 -0
- data/lib/formtastic/inputs/time_zone_input.rb +1 -0
- data/lib/formtastic/inputs/url_input.rb +1 -0
- data/lib/formtastic/inputs.rb +1 -0
- data/lib/formtastic/localized_string.rb +1 -0
- data/lib/formtastic/localizer.rb +1 -0
- data/lib/formtastic/namespaced_class_finder.rb +7 -8
- data/lib/formtastic/version.rb +2 -1
- data/lib/formtastic.rb +7 -2
- data/lib/generators/formtastic/form/form_generator.rb +3 -3
- data/lib/generators/formtastic/input/input_generator.rb +1 -0
- data/lib/generators/formtastic/install/install_generator.rb +1 -1
- data/lib/generators/formtastic/stylesheets/stylesheets_generator.rb +15 -0
- data/{app/assets/stylesheets → lib/generators/templates}/formtastic.css +4 -4
- data/lib/generators/templates/formtastic.rb +8 -1
- data/script/integration-template.rb +16 -14
- data/script/integration.sh +17 -4
- data/spec/action_class_finder_spec.rb +1 -1
- data/spec/actions/button_action_spec.rb +17 -17
- data/spec/actions/generic_action_spec.rb +130 -130
- data/spec/actions/input_action_spec.rb +16 -16
- data/spec/actions/link_action_spec.rb +25 -25
- data/spec/builder/custom_builder_spec.rb +5 -5
- data/spec/builder/error_proc_spec.rb +2 -2
- data/spec/builder/semantic_fields_for_spec.rb +97 -26
- data/spec/fast_spec_helper.rb +1 -1
- data/spec/generators/formtastic/form/form_generator_spec.rb +8 -7
- data/spec/generators/formtastic/input/input_generator_spec.rb +1 -0
- data/spec/generators/formtastic/install/install_generator_spec.rb +1 -0
- data/spec/generators/formtastic/stylesheets/stylesheets_generator_spec.rb +22 -0
- data/spec/helpers/action_helper_spec.rb +15 -14
- data/spec/helpers/actions_helper_spec.rb +42 -42
- data/spec/helpers/form_helper_spec.rb +26 -20
- data/spec/helpers/input_helper_spec.rb +82 -70
- data/spec/helpers/inputs_helper_spec.rb +179 -180
- data/spec/helpers/reflection_helper_spec.rb +4 -4
- data/spec/helpers/semantic_errors_helper_spec.rb +118 -10
- data/spec/i18n_spec.rb +13 -13
- data/spec/input_class_finder_spec.rb +1 -1
- data/spec/inputs/base/collections_spec.rb +43 -0
- data/spec/inputs/base/validations_spec.rb +1 -0
- data/spec/inputs/boolean_input_spec.rb +66 -66
- data/spec/inputs/check_boxes_input_spec.rb +89 -89
- data/spec/inputs/color_input_spec.rb +7 -7
- data/spec/inputs/country_input_spec.rb +15 -15
- data/spec/inputs/custom_input_spec.rb +1 -1
- data/spec/inputs/datalist_input_spec.rb +2 -2
- data/spec/inputs/date_picker_input_spec.rb +109 -109
- data/spec/inputs/date_select_input_spec.rb +63 -63
- data/spec/inputs/datetime_picker_input_spec.rb +118 -118
- data/spec/inputs/datetime_select_input_spec.rb +72 -72
- data/spec/inputs/email_input_spec.rb +16 -16
- data/spec/inputs/file_input_spec.rb +17 -17
- data/spec/inputs/hidden_input_spec.rb +29 -29
- data/spec/inputs/include_blank_spec.rb +7 -7
- data/spec/inputs/label_spec.rb +57 -25
- data/spec/inputs/number_input_spec.rb +159 -159
- data/spec/inputs/password_input_spec.rb +17 -17
- data/spec/inputs/phone_input_spec.rb +16 -16
- data/spec/inputs/placeholder_spec.rb +17 -17
- data/spec/inputs/radio_input_spec.rb +58 -58
- data/spec/inputs/range_input_spec.rb +108 -108
- data/spec/inputs/readonly_spec.rb +5 -5
- data/spec/inputs/search_input_spec.rb +15 -15
- data/spec/inputs/select_input_spec.rb +144 -94
- data/spec/inputs/string_input_spec.rb +103 -37
- data/spec/inputs/text_input_spec.rb +32 -32
- data/spec/inputs/time_picker_input_spec.rb +110 -110
- data/spec/inputs/time_select_input_spec.rb +71 -71
- data/spec/inputs/time_zone_input_spec.rb +21 -21
- data/spec/inputs/url_input_spec.rb +16 -16
- data/spec/inputs/with_options_spec.rb +8 -8
- data/spec/localizer_spec.rb +1 -1
- data/spec/namespaced_class_finder_spec.rb +17 -6
- data/spec/schema.rb +1 -0
- data/spec/spec_helper.rb +10 -9
- data/spec/support/custom_macros.rb +75 -66
- data/spec/support/deprecation.rb +2 -1
- data/spec/support/shared_examples.rb +2 -1
- data/spec/support/specialized_class_finder_shared_example.rb +1 -1
- data/spec/support/test_environment.rb +2 -1
- metadata +65 -37
- data/Gemfile.lock +0 -105
- data/app/assets/stylesheets/formtastic_ie6.css +0 -33
- data/app/assets/stylesheets/formtastic_ie7.css +0 -23
- data/gemfiles/rails_5.2/Gemfile +0 -5
- data/gemfiles/rails_6.0/Gemfile +0 -5
- data/gemfiles/rails_6.1/Gemfile +0 -5
- data/gemfiles/rails_edge/Gemfile +0 -13
- data/lib/formtastic/engine.rb +0 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 211d0d0b33c1ea9fbd35858a71924740a27dd0a39b4e0e0cc48f16e7753388b1
|
|
4
|
+
data.tar.gz: 102435b082e7b83ddcfd874d8fe89f016b622e7f48fea56de0f8a136e162e072
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
data/.github/workflows/test.yml
CHANGED
|
@@ -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-
|
|
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/
|
|
17
|
-
- gemfiles/
|
|
18
|
-
- gemfiles/
|
|
19
|
-
- gemfiles/rails_edge
|
|
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
|
-
-
|
|
23
|
-
- 2
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
29
|
+
- '3.1'
|
|
30
|
+
- '3.2'
|
|
31
|
+
- '3.3'
|
|
32
|
+
- '3.4'
|
|
33
|
+
- '4.0'
|
|
27
34
|
|
|
28
35
|
exclude:
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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@
|
|
51
|
+
- uses: actions/checkout@v6
|
|
46
52
|
|
|
47
|
-
- uses: actions/setup-node@
|
|
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
|
-
|
|
61
|
-
continue-on-error: ${{ matrix.gemfile == 'gemfiles/rails_edge/Gemfile' }}
|
|
67
|
+
continue-on-error: ${{ matrix.gemfile == 'gemfiles/rails_edge.gemfile' }}
|
data/.gitignore
CHANGED
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
|
-
##
|
|
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
data/MIT-LICENSE
CHANGED
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
|
|
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
|
|
20
|
-
* Formtastic
|
|
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', '~>
|
|
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
|
-
|
|
102
|
+
An optional proof-of-concept stylesheet can be generated and installed into your app:
|
|
104
103
|
|
|
105
|
-
|
|
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/
|
|
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
|
-
|
|
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-
|
|
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
|
|
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
|
-
|
|
25
|
-
s.
|
|
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
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
s.
|
|
33
|
-
|
|
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
|
|
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", 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: "../"
|
data/lib/formtastic/actions.rb
CHANGED
|
@@ -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
|
-
|
|
19
|
-
configure :
|
|
20
|
-
configure :
|
|
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 :
|
|
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 :
|
|
42
|
-
configure :
|
|
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
|
-
|
|
47
|
-
configure :
|
|
48
|
-
configure :
|
|
49
|
-
|
|
50
|
-
configure :
|
|
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
|
|