准生证终于在提交了n多文件后又来一个可喜的进展.两口子都是外地人确实有些麻烦.
社区的工作人员从我提供的数十张资料中挑选了所需之后,终于告诉我:下周可以领取准生证了.
p475
基于表单构建器(FormBuilder)的字符辅助方法
下面的方法只有在下面代码块中有效
view plaincopy to clipboardprint?
<% form_for :product,:url=>{:action=>:create} do |form| %>
#在此有效
<% end %>
<% form_for :product,:url=>{:action=>:create} do |form| %>
#在此有效
<% end %>
文本类型
view plaincopy to clipboardprint?
<%= form.text_field :title ,:size=>30,:max_size=>30 %>
<%= form.password_field :title ,:size=>30,:max_size=>30 %>
<%= form.hidden_field :title ,:size=>30,:max_size=>30 %>
<%= form.text_field :title ,:size=>30,:max_size=>30 %>
<%= form.password_field :title ,:size=>30,:max_size=>30 %>
<%= form.hidden_field :title ,:size=>30,:max_size=>30 %>
memo类型
view plaincopy to clipboardprint?
<%= form.textarea_field :title ,:cols=>30,:rows=>30 %>
<%= form.textarea_field :title ,:cols=>30,:rows=>30 %>
单选按钮
view plaincopy to clipboardprint?
<%= form.radio_button :title ,"天蝎"%>
<%= form.radio_button :title ,"白羊"%>
<%= form.radio_button :title ,"天蝎"%>
<%= form.radio_button :title ,"白羊"%>
复选按钮
view plaincopy to clipboardprint?
<%= form.check_box :title ,"男","女"%>
<%= form.check_box :title ,"男","女"%>
下拉列表
view plaincopy to clipboardprint?
<%= form.select :title ,%w{first,second,third,fourth}%>
<%= form.select :title ,[
['1','first'],
['2','second'],
['3','third'],
]%>
#显示1,2,3,传回first,second,third
@users = User.find(:all).map{|u|[u.name,u.id]}
<%= form.select :title ,{@users}%>
$用hash传入,当作select参数,显示键,传回值
<%= form.select :title ,%w{first,second,third,fourth}%>
<%= form.select :title ,[
['1','first'],
['2','second'],
['3','third'],
]%>
#显示1,2,3,传回first,second,third
@users = User.find(:all).map{|u|[u.name,u.id]}
<%= form.select :title ,{@users}%>
$用hash传入,当作select参数,显示键,传回值
下拉框高级方法
view plaincopy to clipboardprint?
<%= form.collect_select :addr_project,@projects,:project_id,:project_name %>
<%= form.collect_select :addr_project,@projects,:project_id,:project_name %>
日期
view plaincopy to clipboardprint?
<%= form.date_select :loan_date %>
<%= form.year_select :loan_date %>
<%= form.date_select :loan_date %>
<%= form.year_select :loan_date %>
上述所有的变体
view plaincopy to clipboardprint?
<%= form.text_field :title ,:size=>30,:max_size=>30 %>
#相当于
<%= text_field :product,:title ,:size=>30,:max_size=>30 %>
<%= form.text_field :title ,:size=>30,:max_size=>30 %>
#相当于
<%= text_field :product,:title ,:size=>30,:max_size=>30 %>
但一个表单中需要多个model对象时,就可以区分
方法是在第一个参数位置,插入模型对象变量
fields_for可以在form_for代码块内部,使用如同form_for的辅助方法,但不创建表单,这样可以解决,同一表单多个model对象的问题
其使用方式如同form_for一般
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jalphi/archive/2010/03/11/5367118.aspx