diff options
author | Hans de Graaff <hans@degraaff.org> | 2022-10-26 13:16:54 +0200 |
---|---|---|
committer | Hans de Graaff <hans@degraaff.org> | 2022-10-26 13:16:54 +0200 |
commit | e4cd3ea76e88f2550b370408c54e8ac6003b2f1a (patch) | |
tree | ba679da0740377d415e324e0251ab381432bbbb0 /dev-ruby | |
parent | dev-ruby/bootstrap_form: fix patch file (diff) | |
download | graaff-e4cd3ea76e88f2550b370408c54e8ac6003b2f1a.tar.gz graaff-e4cd3ea76e88f2550b370408c54e8ac6003b2f1a.tar.bz2 graaff-e4cd3ea76e88f2550b370408c54e8ac6003b2f1a.zip |
dev-ruby/bootstrap_form: fix required attribute patch
Signed-off-by: Hans de Graaff <hans@degraaff.org>
Diffstat (limited to 'dev-ruby')
-rw-r--r-- | dev-ruby/bootstrap_form/files/bootstrap_form-5.1.0-required.patch | 65 |
1 files changed, 62 insertions, 3 deletions
diff --git a/dev-ruby/bootstrap_form/files/bootstrap_form-5.1.0-required.patch b/dev-ruby/bootstrap_form/files/bootstrap_form-5.1.0-required.patch index 3c3b359a..09deffd4 100644 --- a/dev-ruby/bootstrap_form/files/bootstrap_form-5.1.0-required.patch +++ b/dev-ruby/bootstrap_form/files/bootstrap_form-5.1.0-required.patch @@ -1,13 +1,72 @@ diff --git a/lib/bootstrap_form/form_group_builder.rb b/lib/bootstrap_form/form_group_builder.rb -index 6bd733e..c173d76 100644 +index 6bd733e..a48ef7c 100644 --- a/lib/bootstrap_form/form_group_builder.rb +++ b/lib/bootstrap_form/form_group_builder.rb -@@ -28,7 +28,7 @@ module BootstrapForm +@@ -28,7 +28,8 @@ module BootstrapForm def form_group_builder_options(options, method) options.symbolize_keys! options = convert_form_tag_options(method, options) if acts_like_form_tag - options[:required] = form_group_required(options) if !options[:skip_label] && options.key?(:skip_required) -+ options[:required] = form_group_required(options) if !options[:skip_label] ++ options[:required] = form_group_required(options, method) ++ options[:aria] = { required: true } if options[:required] options end +@@ -77,11 +78,15 @@ module BootstrapForm + classes + end + +- def form_group_required(options) +- return unless options.key?(:skip_required) +- +- warn "`:skip_required` is deprecated, use `:required: false` instead" +- options[:skip_required] ? false : :default ++ def form_group_required(options, method) ++ if options[:skip_required] ++ warn "`:skip_required` is deprecated, use `:required: false` instead" ++ false ++ elsif options.key?(:required) ++ options[:required] ++ else ++ required_attribute?(object, method) ++ end + end + + def form_group_css_options(method, html_options, options) +diff --git a/lib/bootstrap_form/inputs/check_box.rb b/lib/bootstrap_form/inputs/check_box.rb +index 8ad1069..5fba7af 100644 +--- a/lib/bootstrap_form/inputs/check_box.rb ++++ b/lib/bootstrap_form/inputs/check_box.rb +@@ -9,14 +9,11 @@ module BootstrapForm + included do + def check_box_with_bootstrap(name, options={}, checked_value="1", unchecked_value="0", &block) + options = options.symbolize_keys! +- check_box_options = options.except(:class, :label, :label_class, :error_message, :help, +- :inline, :hide_label, :skip_label, :wrapper, :wrapper_class, :switch) +- check_box_options[:class] = check_box_classes(name, options) + + tag.div(class: check_box_wrapper_class(options), **options[:wrapper].to_h.except(:class)) do +- html = check_box_without_bootstrap(name, check_box_options, checked_value, unchecked_value) +- html << check_box_label(name, options, checked_value, &block) unless options[:skip_label] +- html << generate_error(name) if options[:error_message] ++ html = check_box_without_bootstrap(name, check_box_options(name, options), checked_value, unchecked_value) ++ html.concat(check_box_label(name, options, checked_value, &block)) unless options[:skip_label] ++ html.concat(generate_error(name)) if options[:error_message] + html + end + end +@@ -26,6 +23,14 @@ module BootstrapForm + + private + ++ def check_box_options(name, options) ++ check_box_options = options.except(:class, :label, :label_class, :error_message, :help, ++ :inline, :hide_label, :skip_label, :wrapper_class, :switch) ++ check_box_options[:class] = check_box_classes(name, options) ++ check_box_options[:aria] = { required: true } if options[:required] ++ check_box_options ++ end ++ + def check_box_label(name, options, checked_value, &block) + label_name = if options[:multiple] + check_box_value(name, checked_value) |