Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I wanted to the Twitter Bootstrap icons to a basic Rails form and came across this post. After searching around a bit, I figured out an easy way to do it. Not sure if you're using Rails, but here's the code. The key was to pass a block to the link_to view helper: </p> <pre><code>&lt;tbody&gt; &lt;% @products.each do |product| %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= product.id %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= link_to product.name, product_path(product) %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= product.created_at %&gt;&lt;/td&gt; &lt;td&gt; &lt;%= link_to(edit_product_path(product), :class =&gt; 'btn btn-mini') do %&gt; Edit &lt;i class="icon-pencil"&gt;&lt;/i&gt; &lt;% end %&gt; &lt;%= link_to(product_path(product), :method =&gt; :delete, :confirm =&gt; 'Are you sure?', :class =&gt; 'btn btn-mini btn-danger') do %&gt; Delete &lt;i class="icon-trash icon-white"&gt;&lt;/i&gt; &lt;% end %&gt; &lt;/td&gt; &lt;/tr&gt; &lt;% end %&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;%= link_to(new_product_path, :class =&gt; 'btn btn-primary') do %&gt; New &lt;i class="icon-plus icon-white"&gt;&lt;/i&gt; &lt;% end %&gt; </code></pre> <p>In case you're not using Rails, here is the output HTML for the links with icons (for an edit, delete, and new submit buttons)</p> <pre><code># Edit &lt;a href="/products/1/edit" class="btn btn-mini"&gt;Edit &lt;i class="icon-pencil"&gt;&lt;/i&gt;&lt;/a&gt; # Delete &lt;a href="/products/1" class="btn btn-mini btn-danger" data-confirm="Are you sure?" data-method="delete" rel="nofollow"&gt; Delete &lt;i class="icon-trash icon-white"&gt;&lt;/i&gt;&lt;/a&gt; # New &lt;a href="/products/new" class="btn btn-primary"&gt;New &lt;i class="icon-plus icon-white"&gt;&lt;/i&gt;&lt;/a&gt; </code></pre> <p>And here's a link to screenshot of the finished result: <a href="http://grab.by/cVXm">http://grab.by/cVXm</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload