學習足跡

2013年5月25日 星期六

Rails Form Helper使用說明

表單欄位

名稱 用途
form_tag 產生表單
label_tag label:<label>
text_field_tag
text_field
input text:<input type="text">
password_field_tag input password:<input type="password">
hidden_field_tag input hidden:<input type="hidden">
submit_tag input submit:<input type="submit">
check_box_tag input checkbox:<input type="checkbox">
radio_button_tag input radio:<input type="radio">
text_area_tag textarea:<textarea>
search_field input search:<input type="search">
telephone_field input tel:<inputtype="tel">
url_field input url:<input type="url">
email_field input email:<input type="email">
select_tag select:<select>
options_for_select option:<option>
select_date <select id="start_date_year" name="start_date[year]"></select> <select id="start_date_month" name="start_date[month]"></select> <select id="start_date_day" name="start_date[day]"></select>
file_field_tag input file:<input type="file">




範例說明

form_tag


label_tag
text_field_tag
text_field
submit_tag
check_box_tag
radio_button_tag
password_field_tag
hidden_field_tag
text_area_tag
search_field
telephone_field
hidden_field_tag
email_field
select_tag
options_for_select




欄位參數


名稱 用途
form_tag
:multipart => true
enctype="multipart/form-data"
:method => "get"
<form method="get">
:method => "post"
<form method="post">
:method => "put"
<input name="_method" type="hidden" value="put">
:method => "delete"
<input name="_method" type="hidden" value="delete">
text_field
:value=> "欄位文字"
value="欄位文字"
:placeholder => "預設文字"
placeholder ="預設文字"
:class=>"classname"
class="classname"
text_area_tag
:size => "24x6"
cols="24" rows="6"

進階應用


在表單使用PUT 或 DELETE




參考資料

沒有留言:

張貼留言