remove a blank option of select field that was generated by SimpleForm

前端 未结 3 2049
闹比i
闹比i 2021-02-03 17:48

I have this piece of code:

= f.input :category, :as => :select, :label => false, :collection => Choices[\"Categories\"]

Choices[\"Cate

3条回答
  •  野性不改
    2021-02-03 17:51

    To remove a blank field from select it is necessary to show the selected so add selected: 1 Then set prompt to anything like prompt: "Please Select" The final output will be <%= select("social_links",:option_id, Option.all.collect {|p| [ p.name, p.id ] },{ selected: 1 , prompt: "Please Select"}, { class: 'form-control' , required:true})%>

提交回复
热议问题