簡體   English   中英

如何將一個格式化按鈕變成鏈接?

[英]How to turn a formtastic button into a link?

我試圖將我的表格提交按鈕設置為鏈接而不是按鈕。

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

並且上面給了我一個“ Formtastic :: UnsupportedMethodForAction”錯誤。

我從rdoc.info/github/justinfrench/formtastic#The_Available_Inputs找到了以下示例代碼

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

如果我將以上代碼更改為

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

:as =>:link不支持:submit嗎?

提前致謝!

它將生成<input type="button" value="Sign in">

如果您想要一個響應動作的鏈接,請使用link_to "Profile", :controller => "profiles", :action => "create", :id => @profile, :method => :post

您應該使用CSS來完成此操作。 嘗試類似

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM