http://www.blogjava.net/wldandan/archive/2007/12/15/167920.html
初学者必备
表单开始标签:
Use :multipart => true to define a Mime-Multipart form (for file uploads)
表单结束标签:
文本框 Text fields
生成:
实例:
text_field "post", "title", "size" => 20
size="20" value="#{@post.title}" />
隐藏框:
密码框:
文件框
Rails Textarea框
实例:
text_area "post", "body", "cols" => 20, "rows" => 40
<br />
<a href="mailto:#%7B@post.body" _fcksavedurl="mailto:#%7B@post.body"><font color="#0000ff">#{@post.body</font></a>}<br />
单选框 Radio Buttons
实例:
radio_button "post", "category", "rails"
radio_button "post", "category", "java"
value="rails"
checked="checked" />
value="java" />
多选框 Check Box
实例
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 }
value="1" selected="selected">David value="2">Sam value="3">Tobias
Collection Selection
日期选择框:
实例:
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"
Ruby on Rails HTML表单语句大全
最新推荐文章于 2024-11-14 09:59:03 发布