我正在使用simple_form
Rails 3.2 上的 gem 创建一个表单。
我遇到的问题是我希望在我的表单行中添加一个font-awesome
图标。f.button :submit
由于输出是类型,input
我无法在其中嵌入图标元素。
我可以简单地将submit
按钮硬编码到包含图标的表单中,但我不确定如何获取按钮值 - Create %model
/ Update %model
。
我的代码发布在下面:
<div id="form">
<%= simple_form_for @program, :html => { :class => 'form-horizontal' } do |f| %>
<%= f.input :name %>
<%= f.input :url %>
<%= f.input :description, :input_html => { :class => "span5", :rows => 10 } %>
*********************
<%= f.button :submit do %>
<i class="icon-save"></i> What Here??? <--- Doesn't work since output is type input
<% end %>
*********************
<button class="btn">
<i class="icon-save"></i> <%= f.button(:submit).label %> <--- Doesn't work, alternative?
</button>
<% end %>
</div>
预期输出:
<button type="submit" class="btn">
<i class="icon-plus-sign"></i> Create *ModelName*
</button>
或更新ModelName,具体取决于控制器操作。