Can I include blank field in select_tag?

前端 未结 4 1934
栀梦
栀梦 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:24

    The select_tag method does not modify the options list you pass it. If you want a blank option you have to include it in your list of options.

    If you're using options_for_select your list should start with the blank item, ie: ["Please select", ''].

    If you're just passing html to select_tag make sure your first option is:

    
    

提交回复
热议问题