Ruby on Rails HTML表单语句大全


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"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值