Rails 3 Submit Tag + html_safe

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 21:38:01
Noz

To extend on Lukas' answer I needed a button tag rather than an input. This code produced the effect I was looking for:

<button type="submit" class="btn btn-danger">
    Delete <i class="icon-check"></i> 
</button>

Which resulted in:

I found the answer I was looking for here.

What's wrong with it? Submit button values should not contain embedded HTML code.

This is how submit button looks in HTML:

<input type="submit" value="Submit" />

HTML tags in value attributes are interpreted as text, not as HTML:

<input type="submit" value="<i>Submit</i>" />

<%= form.button :submit, class: 'btn btn-success' do %>
     <i class="fa fa-plus"></i> Add Funder <i class="fa fa-chevron-right"></i>
<% end %>

This is good answer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!