Skip to content

Commit c88fe8a

Browse files
nofaralfasiekohl
authored andcommittedMar 18, 2025
Fixes #38281 - Refactor handling of :include_blank in form_select_f
Ensure proper handling of `include_blank` in both cases: when `array` is an array of options, and when `array` is a string of HTML options. (cherry picked from commit 316dd2d)
1 parent 9ff8472 commit c88fe8a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎app/helpers/form_helper.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -442,14 +442,15 @@ def get_attr_error(f, attr)
442442

443443
def form_select_f(f, attr, array, select_options = {}, html_options = {})
444444
addClass html_options, "form-control"
445-
include_blank = select_options.delete(:include_blank)
445+
include_blank = select_options[:include_blank]
446446
if include_blank
447447
addClass html_options, "include_blank"
448448
blank_value = include_blank.is_a?(TrueClass) ? nil : include_blank
449449
if array.kind_of?(Array) # incase array is options_for_select
450450
array = array.to_a.dup
451451
blank_option = [blank_value, nil]
452452
array.insert(0, blank_option)
453+
select_options.delete(:include_blank)
453454
end
454455
html_options['data-placeholder'] = blank_value || html_options[:placeholder]
455456
elsif html_options[:placeholder]

0 commit comments

Comments
 (0)