rails include_blank和fontawesome图标

时间:2018-03-11 20:55:24

标签: ruby-on-rails drop-down-menu font-awesome

我可以使用字体真棒图标作为包含空白项目 铁路选择标签?

https://apidock.com/rails/ActionView/Helpers/FormTagHelper/select_tag

我尝试了什么

<%= select_tag "near_within_distance",                                                                       
    options_for_select([                                                                                     
    ["Male", "50m "],                                                                                        
    ["Female", "f"],                                                                                         
    ], params[:near_within_distance]),                                                                       
    class: "form-control zcustom-select mr-sm-1",                                                            
    include_blank: "<i class='fa fa-search'></i>".html_safe %>    

导致

<select name="near_within_distance" id="near_within_distance" class="form-control zcustom-select mr-sm-1"><option value=""></option><option value="50m ">Male</option>
<option value="f">Female</option></select>

1 个答案:

答案 0 :(得分:0)

custom.css

@import url("http://fontawesome.io/assets/font-awesome/css/font-awesome.css");
select { font-family: 'FontAwesome', Verdana }

new.erb

<%= select_tag "near_within_distance",                                                                       
    options_for_select([                                                                                     
    ["Male", "50m "],                                                                                        
    ["Female", "f"],                                                                                         
    ], params[:near_within_distance]),                                                                       
    class: "form-control zcustom-select mr-sm-1",                                                            
    include_blank: "&#xf042;".html_safe %>   

其中“&amp;#xf042”是字体很棒的代码。你可以尝试任何人从字体真棒库。