[英]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. 并且上面给了我一个“ Formtastic :: UnsupportedMethodForAction”错误。
I found the following sample code from rdoc.info/github/justinfrench/formtastic#The_Available_Inputs 我从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 ? :as =>:link不支持:submit吗?
Thanks in advance! 提前致谢!
It will generate <input type="button" value="Sign in">
它将生成
<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
如果您想要一个响应动作的链接,请使用
link_to "Profile", :controller => "profiles", :action => "create", :id => @profile, :method => :post
You should rather do this using CSS. 您应该使用CSS来完成此操作。 Try something like
尝试类似
#submit-button-selector {
background: none;
border: none;
color: blue;
text-decoration: underline;
display: inline;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.