Ruby on Rails HTML表單語句大全[Z]

CharlesCui發表於2008-03-24

表單開始標籤:
:save }, { :method => :post } %>
Use :multipart => true to define a Mime-Multipart form (for file uploads)
表單結束標籤:

文字框 Text fields
生成:

例項:

text_field "post", "title", "size" => 20
size="20" value="}" />

隱藏框:

密碼框:

檔案框

Rails Textarea框

例項:
text_area "post", "body", "cols" => 20, "rows" => 40

單選框 Radio Buttonsvalue, options %>
例項:
radio_button "post", "category", "rails"
radio_button "post", "category", "java"
value="rails"
checked="checked" />
value="java" />

多選框 Check Box
value, off_value %>
例項
check_box "post", "validated" # post.validated? returns 1 or 0
value="1" checked="checked" />
value="0" />

check_box "puppy", "gooddog", {}, "yes", "no"
value="yes" />
value="no" />

下拉選單框 Select Menu
select "post",
"person_id",
Person.find_all.collect {|p| [ p.name, p.id ] },
{ :include_blank => true }

Collection Selection
value %>

日期選擇框:


例項:
date_select "post", "written_on"
date_select "user", "birthday", :start_year => 1910
date_select "user", "cc_date", :start_year => 2005,
:use_month_numbers => true,
:discard_day => true,
:order => [:year, :month]

datetime_select "post", "written_on"

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9934490/viewspace-1001387/,如需轉載,請註明出處,否則將追究法律責任。

相關文章