From 91967e9d70e43fb60b80537427e97f8ec5185304 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Wed, 11 Aug 2021 13:03:38 +0000 Subject: [PATCH] Update formtastic to version 4.0.0 --- Gemfile | 2 +- Gemfile.lock | 14 ++++---- config/initializers/formtastic.rb | 36 ++++++++++----------- lib/templates/haml/scaffold/_form.html.haml | 8 +++++ 4 files changed, 33 insertions(+), 27 deletions(-) create mode 100644 lib/templates/haml/scaffold/_form.html.haml diff --git a/Gemfile b/Gemfile index a8f07f25..bfbf07f5 100644 --- a/Gemfile +++ b/Gemfile @@ -77,7 +77,7 @@ gem 'uglifier', '>= 1.3.0' gem 'autoprefixer-rails' gem 'bootstrap-sass', '~> 3.4.0' gem 'cocoon' -gem 'formtastic', '~> 3.1.5' +gem 'formtastic', '~> 4.0.0' gem 'formtastic-bootstrap' # as the JavaScript library diff --git a/Gemfile.lock b/Gemfile.lock index 73e60f60..55d8d439 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -201,8 +201,8 @@ GEM font-awesome-rails (4.7.0.7) railties (>= 3.2, < 7) formatador (0.2.5) - formtastic (3.1.5) - actionpack (>= 3.2.13) + formtastic (4.0.0) + actionpack (>= 5.2.0) formtastic-bootstrap (3.1.1) formtastic (>= 3.0) geckodriver-helper (0.24.0) @@ -292,7 +292,7 @@ GEM rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) - loofah (2.10.0) + loofah (2.11.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) lumberjack (1.0.12) @@ -311,7 +311,7 @@ GEM rake mini_magick (4.11.0) mini_mime (1.1.0) - mini_portile2 (2.5.3) + mini_portile2 (2.6.1) minitest (5.14.4) momentjs-rails (2.20.1) railties (>= 3.1) @@ -331,8 +331,8 @@ GEM nenv (0.3.0) netrc (0.11.0) nio4r (2.5.7) - nokogiri (1.11.7) - mini_portile2 (~> 2.5.0) + nokogiri (1.12.3) + mini_portile2 (~> 2.6.1) racc (~> 1.4) notiffany (0.1.1) nenv (~> 0.1) @@ -670,7 +670,7 @@ DEPENDENCIES faker feature font-awesome-rails - formtastic (~> 3.1.5) + formtastic (~> 4.0.0) formtastic-bootstrap geckodriver-helper gravtastic diff --git a/config/initializers/formtastic.rb b/config/initializers/formtastic.rb index f21da2e7..a50ea310 100644 --- a/config/initializers/formtastic.rb +++ b/config/initializers/formtastic.rb @@ -15,17 +15,17 @@ # Should select fields have a blank option/prompt by default? # Defaults to true. -Formtastic::FormBuilder.include_blank_for_select_by_default = false +# Formtastic::FormBuilder.include_blank_for_select_by_default = true -# Set the string that will be appended to the labels/fieldsets which are required +# Set the string that will be appended to the labels/fieldsets which are required. # It accepts string or procs and the default is a localized version of # '*'. In other words, if you configure formtastic.required # in your locale, it will replace the abbr title properly. But if you don't want to use -# abbr tag, you can simply give a string as below -Formtastic::FormBuilder.required_string = proc { Formtastic::Util.html_safe(%{ *}) } +# abbr tag, you can simply give a string as below. +# Formtastic::FormBuilder.required_string = "(required)" -# Set the string that will be appended to the labels/fieldsets which are optional -# Defaults to an empty string ("") and also accepts procs (see required_string above) +# Set the string that will be appended to the labels/fieldsets which are optional. +# Defaults to an empty string ("") and also accepts procs (see required_string above). # Formtastic::FormBuilder.optional_string = "(optional)" # Set the way inline errors will be displayed. @@ -33,7 +33,7 @@ Formtastic::FormBuilder.required_string = proc { Formtastic::Util.html_safe(%{&n # Formtastic::FormBuilder.inline_errors = :sentence # Formtastic uses the following classes as default for hints, inline_errors and error list -# If you override the class here, please ensure to override it in your stylesheets as well +# If you override the class here, please ensure to override it in your stylesheets as well. # Formtastic::FormBuilder.default_hint_class = "inline-hints" # Formtastic::FormBuilder.default_inline_error_class = "inline-errors" # Formtastic::FormBuilder.default_error_list_class = "errors" @@ -70,7 +70,7 @@ Formtastic::FormBuilder.required_string = proc { Formtastic::Util.html_safe(%{&n # can change it to any class you want. # Formtastic::Helpers::FormHelper.default_form_class = 'formtastic' -# Formtastic will infer a class name from the model, array, string ot symbol you pass to the +# Formtastic will infer a class name from the model, array, string or symbol you pass to the # form builder. You can customize the way that class is presented by overriding # this proc. # Formtastic::Helpers::FormHelper.default_form_model_class_proc = proc { |model_class_name| model_class_name } @@ -85,18 +85,14 @@ Formtastic::FormBuilder.required_string = proc { Formtastic::Util.html_safe(%{&n # Formtastic::FormBuilder.use_required_attribute = false # You can opt-in to new HTML5 browser validations (for things like email and url inputs) by setting -# this to true. Doing so will add a `novalidate` attribute to the `
` tag. +# this to true. Doing so will omit the `novalidate` attribute from the `` tag. # See http://diveintohtml5.org/forms.html#validation for more info. -Formtastic::FormBuilder.perform_browser_validations = true -# -Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder -FormtasticBootstrap::FormBuilder.default_inline_hint_class = FormtasticBootstrap::FormBuilder.default_block_hint_class +# Formtastic::FormBuilder.perform_browser_validations = true # By creating custom input class finder, you can change how input classes are looked up. # For example you can make it to search for TextInputFilter instead of TextInput. -# See # TODO: add link # for more information -# NOTE: this behavior will be default from Formtastic 4.0 -Formtastic::FormBuilder.input_class_finder = Formtastic::InputClassFinder +# See https://github.com/formtastic/formtastic/wiki/Custom-Class-Finders +# Formtastic::FormBuilder.input_class_finder = Formtastic::InputClassFinder # Define custom namespaces in which to look up your Input classes. Default is # to look up in the global scope and in Formtastic::Inputs. @@ -104,10 +100,12 @@ Formtastic::FormBuilder.input_class_finder = Formtastic::InputClassFinder # By creating custom action class finder, you can change how action classes are looked up. # For example you can make it to search for MyButtonAction instead of ButtonAction. -# See # TODO: add link # for more information -# NOTE: this behavior will be default from Formtastic 4.0 -Formtastic::FormBuilder.action_class_finder = Formtastic::ActionClassFinder +# See https://github.com/formtastic/formtastic/wiki/Custom-Class-Finders +# Formtastic::FormBuilder.action_class_finder = Formtastic::ActionClassFinder # Define custom namespaces in which to look up your Action classes. Default is # to look up in the global scope and in Formtastic::Actions. # Formtastic::FormBuilder.action_namespaces = [ ::Object, ::MyActionsModule, ::Formtastic::Actions ] + +# Which columns to skip when automatically rendering a form without any fields specified. +# Formtastic::FormBuilder.skipped_columns = [:created_at, :updated_at, :created_on, :updated_on, :lock_version, :version] diff --git a/lib/templates/haml/scaffold/_form.html.haml b/lib/templates/haml/scaffold/_form.html.haml new file mode 100644 index 00000000..de6af813 --- /dev/null +++ b/lib/templates/haml/scaffold/_form.html.haml @@ -0,0 +1,8 @@ += semantic_form_for @<%= singular_name %> do |f| + = f.inputs do + <%- attributes.each do |attribute| -%> + = f.input :<%= attribute.name %> + <%- end -%> + + = f.actions do + = f.action :submit, :as => :input