I'm creating a form using the simple_form
gem on Rails 3.2.
The problem I'm having is that I wish to add a font-awesome
icon to the f.button :submit
line of my form. Since the output is of type input
I can't embed the icon element inside of it.
I could simply hardcode a submit
button into the form that contains the icon but I am not sure how to fetch the button value - Create %model
/ Update %model
.
My code is posted below:
<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>
Expected output:
<button type="submit" class="btn">
<i class="icon-plus-sign"></i> Create *ModelName*
</button>
Or Update ModelName , depending on controller action.
<%= f.button do %>
<i class="icon-save"></i> <%= "#{f.object.new_record? ? 'Create' : 'Update'} #{f.object.class.model_name.human}" %>
<% end %>
It would be better to make some helper method for this. If you want to use I18n take a look at source code ( button
and submit_default_value
methods, lines 1763 and 1776 ). It's pretty clear.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.