Search code examples
ruby-on-railssimple-formfont-awesomehtml-safe

Rail simple_form label_method with html


what i am making a select where you can choose an icon that comes from font-awesome. At the hearing I do it this way, but does not work ... only shows options blank. Without html_safe tag created hile shown but logically is text only. The raw method did not work.

<%= f.input :icon, :collection => ["car", "cutlery", "male", "paw", "suitcase", "video-camara", "wheelchair", "calculator", "anchor", "archive", "bell-o", "plug", "wifi", "wrench", "road", "home", "hdd-o", "building-o"], label_method: ->(obj){ raw "<i class=\"fa fa-#{obj}\"></i>" } %>

Solution

  • try this

    label_html: {class: "fa fa-#{obj}"}