Change Text of Blank Option in a Rails Select Tag
The form helper select tag (ex - f.select
) accepts a boolean option for include_blank
, which informs the select tag to have an extra blank option. Setting include_blank: true
will look like the below -
But you can also pass a string to include_blank
and this will change the text content of the blank option -
<%= f.select :state, options_for_select(state_options), {include_blank: 'Select a State'} %>
https://devdocs.io/rails~7.1/actionview/helpers/formtaghelper#method-i-select_tag
Tweet