Search code examples
ruby-on-railsruby-on-rails-3formtastic

How to turn a formtastic button into a link?


I am trying to style my formtastic submit button as a link instead of a button.

<%= f.actions do %>
  <%= f.action :submit, :label => "Sign in", :as => :link %>
<% end %>

and the above gives me a "Formtastic::UnsupportedMethodForAction" error.

I found the following sample code from rdoc.info/github/justinfrench/formtastic#The_Available_Inputs

<%= f.actions do %>
  <%= f.action :submit, :as => :button %>
  <%= f.action :cancel, :as => :link %>
<% end %>

and the above code will fail also if I change it to

<%= f.action :submit, :as => :link %>

is the :as => :link not supported for :submit ?

Thanks in advance!


Solution

  • It will generate <input type="button" value="Sign in">

    If you want an link that responds to an action use link_to "Profile", :controller => "profiles", :action => "create", :id => @profile, :method => :post