简体   繁体   中英

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!

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

You should rather do this using CSS. Try something like

#submit-button-selector {
  background: none;
  border: none;
  color: blue;
  text-decoration: underline;
  display: inline;
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM