Can I include blank field in select_tag?

前端 未结 4 1933
栀梦
栀梦 2020-12-17 08:58

Is it possible to add an option like :include_blank => \'Please Select\' in a method select_tag like it is possible with the select

4条回答
  •  情话喂你
    2020-12-17 09:23

    By passing include_blank: true or prompt: 'Please select' as a third parameter to select_tag

    <%= select_tag "individual[address][state]", options_for_select(states), { include_blank: true, class: 'form-control' } %>
    

    For prompt, you can use like this with select_tag

    <%= select_tag "individual[address][state]", options_for_select(indian_states), { prompt: 'Please select', class: 'form-control' } %>
    

提交回复
热议问题