The include_blank: option wants a hash or text to fill the "blank" option, but an actually blank string option won't be present? and thus fail to register. And setting it to true (as one would for a select box) renders the literal true
To Reproduce
<!-- Renders "true" -->
<%= f.combobox :thing_id, Thing.all, include_blank: true %>
<!-- No blank, because not present? -->
<%= f.combobox :thing_id, Thing.all, include_blank: "" %>
<!-- Renders an invisible non-breaking space character successfully -->
<%= f.combobox :thing_id, Thing.all, include_blank: " ".html_safe %>
Screenshots
Additional context
My advice would be to add a final else to this that just renders a string. Something like this maybe?
def extract_blank_display_and_content
if include_blank.is_a? Hash
text = include_blank.delete(:text)
[ text, render_content(render_opts: include_blank, object: text, attrs: { display: text, value: "" }) ]
elsif include_blank.is_a?(String)
[ include_blank, include_blank ]
else
[ "", nil ]
end
end
Describe the bug
The
include_blank:
option wants a hash or text to fill the "blank" option, but an actually blank string option won't be present? and thus fail to register. And setting it totrue
(as one would for a select box) renders the literaltrue
To Reproduce
Screenshots
Additional context
My advice would be to add a final else to this that just renders a string. Something like this maybe?