Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #38281 - Refactor handling of :include_blank in form_select_f #10484

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/helpers/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -442,14 +442,15 @@ def get_attr_error(f, attr)

def form_select_f(f, attr, array, select_options = {}, html_options = {})
addClass html_options, "form-control"
include_blank = select_options.delete(:include_blank)
include_blank = select_options[:include_blank]
if include_blank
addClass html_options, "include_blank"
blank_value = include_blank.is_a?(TrueClass) ? nil : include_blank
if array.kind_of?(Array) # incase array is options_for_select
array = array.to_a.dup
blank_option = [blank_value, nil]
array.insert(0, blank_option)
select_options.delete(:include_blank)
end
html_options['data-placeholder'] = blank_value || html_options[:placeholder]
elsif html_options[:placeholder]
Expand Down
Loading