Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add font awesome icon to rails submit

I have a f.submit in a form. I want to add a font awesome icon to it. But Im not able to.

<%= f.submit "Register", class: "button my-button", id: "register-button" %>

how can I add a font awesome icon <i class="fa fa-lock" aria-hidden="true"></i> to it ??

like image 298
smanvi12 Avatar asked Nov 29 '22 09:11

smanvi12


2 Answers

another alternative is button_tag

<%= button_tag type: 'submit', class: "button my-button", id: "register-button" do %>
    <i class="fa fa-lock" aria-hidden="true"></i>
<% end %>
like image 93
mrvncaragay Avatar answered Dec 21 '22 05:12

mrvncaragay


With gem font-awesome

<%= f.button fa_icon("lock", text: "Register"), class: "button my-button", id: "register-button" %>

With plain Rails:

 <%= f.button'<i class="fa fa-lock" aria-hidden="true"></i> Register'.html_safe, class: "button my-button", id: "register-button" %>
like image 24
slowjack2k Avatar answered Dec 21 '22 03:12

slowjack2k