Last active
December 17, 2015 17:39
-
-
Save kejyun/5648002 to your computer and use it in GitHub Desktop.
Rails Helper Form For
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 程式:沒有參數--> | |
<%= form_tag do %> | |
表單資料 | |
<% end %> | |
<!-- 輸出 --> | |
<form accept-charset="UTF-8" action="/" method="post"> | |
<div style="margin:0;padding:0;display:inline"> | |
<input name="utf8" type="hidden" value="✓" /> | |
<input name="authenticity_token" type="hidden" value="s1h4sM75vOxLx25I7R9Y0jXlpV+8LsA5Kpp+l2GcLkg=" | |
/> | |
</div> | |
表單資料 | |
</form> | |
<!------------------ 強大的分隔線 ------------------> | |
<!-- 程式:加入action及method --> | |
<%= form_tag("/search", :method => "get") do %> | |
表單資料 | |
<% end %> | |
<!-- 輸出 --> | |
<form accept-charset="UTF-8" action="/search" method="get"> | |
<div style="margin:0;padding:0;display:inline"> | |
<input name="utf8" type="hidden" value="✓" /> | |
</div> | |
表單資料 | |
</form> | |
<!------------------ 強大的分隔線 ------------------> | |
<!-- 程式:加入欄位 --> | |
<%= form_tag("/search", :method => "get") do %> | |
<%= label_tag(:q, "Search for:") %> | |
<%= text_field_tag(:q) %> | |
<%= submit_tag("Search") %> | |
<% end %> | |
<!-- 輸出 --> | |
<form accept-charset="UTF-8" action="/search" method="get"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /></div> | |
<label for="q">Search for:</label> | |
<input id="q" name="q" type="text" /> | |
<input name="commit" type="submit" value="Search" /> | |
</form> | |
<!------------------ 強大的分隔線 ------------------> | |
<!-- 程式:多參數controller,action,method,class --> | |
<%=form_tag( :controller=> "user", | |
:action => "new", | |
:method => "get", | |
:class => "nifty_form") | |
do %> | |
<% end %> | |
<!-- 輸出 --> | |
<form accept-charset="UTF-8" action="/user/new?class=nifty_form&method=get" | |
method="post"> | |
<div style="margin:0;padding:0;display:inline"> | |
<input name="utf8" type="hidden" value="✓" /> | |
<input name="authenticity_token" type="hidden" value="s1h4sM75vOxLx25I7R9Y0jXlpV+8LsA5Kpp+l2GcLkg=" /> | |
</div> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment