2

I am wondering how I can get formtastic to render submit buttons as:

<button … >

Rather than:

<input type="submit" … >

Any ideas?

2
  • I am interested in this too... anyone have any ideas?
    – Marc W
    Sep 13, 2011 at 15:57
  • As I understand it the button element will submit different values for different browsers, so you may want to stick with input. :-) Oct 15, 2011 at 18:37

2 Answers 2

1

I'm not a contributor, but I'd guess it's because of the richer visual rendering possibilities of the button element. The only problem with the button element is supporting older versions of IE (notably IE6) and trying to pass name/value pairs through the button. If you don't need to support IE6, the button element works great, implicitly submits when clicked, passes name/value pairs with the request, and can contain arbitrary HTML.

Good discussion of the pros/cons here:

<button> vs. <input type="button" />. Which to use?

0

This may be what you are looking for.

This is an excerpt from formtastic/lib/formtastic/actions/button_action.rb on Github:

#   <%= semantic_form_for(@post) do |f| %>
#     <%= f.actions do %>
#       <%= f.action :reset, :as => :button %>
#       <%= f.action :submit, :as => :button %>
#     <% end %>
#   <% end %>
#
#   <form...>
#     <fieldset class="actions">
#       <ol>
#         <li class="action button_action" id="post_reset_action">
#           <button type="reset" value="Reset">
#         </li>
#         <li class="action button_action" id="post_submit_action">
#           <button type="submit" value="Create Post">
#         </li>
#       </ol>
#     </fieldset>
#   </form>

And if this doesn't do exactly what you are looking for, you can always fork Formtastic!

References

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.