rails 表单form
来源:互联网 发布:sqlserver with as 编辑:程序博客网 时间:2024/05/22 15:06
基础总结
表单开始标签:
<%= form_tag { :action => :save }, { :method => :post } %>
Use :multipart => true to define a Mime-Multipart form (for file uploads)
表单结束标签:
<%= end_form_tag %>
文本框 Text fields
<%= text_field :modelname, :attribute_name, options
生成:
<input type="text" name="modelname[attribute_name]" id="attributename" />
实例:
text_field "post", "title", "size" => 20
隐藏框:
<%= hidden_field ... %>
密码框:
<%= password_field ... %>
文件框
<%= file_field ... %>
Rails Textarea框
<%= text_area ... %>
实例:
text_area "post", "body", "cols" => 20, "rows" => 40
单选框 Radio Buttons
<%= radio_button :modelname, :attribute, :tag_value, options %>
实例:
radio_button "post", "category", "rails"
radio_button "post", "category", "java"
多选框 Check Box
<%= check_box :modelname, :attribute, options, on_value, off_value %>
实例
check_box "post", "validated"
check_box "puppy", "gooddog", {}, "yes", "no"
<%= select :variable, :attribute, choices, options, html_options %>
下拉菜单框 Select Menu
select
<select name="post[person_id]">
</select>
Collection Selection
<%= collection_select :variable, :attribute, choices, :id, :value %>
日期选择框:
<%= date_select :variable, :attribute, options %>
<%= datetime_select :variable, :attribute, options %>
实例:
date_select "post", "written_on"
date_select "user", "birthday", :start_year => 1910
date_select "user", "cc_date", :start_year => 2005,
datetime_select "post", "written_on"
Rails中两种不同的表单处理方式
1.表单类型一
<div class=""class="form">
此种是对象绑定的方式,通过表单,跟Model层的对象绑定,通常完成数据的增,改功能。
2.表单类型二
<div class=""class="form">
此种主要是为了表单传值
form_for和model绑定,而form_tag不是
form_tag想传什么参数都行,没有约束
- rails 表单form
- rails 表单form
- rails中的form表单总结
- rails中的form表单总结
- rails中的form表单总结
- rails上传文件时,实现form表单自动提交
- FORM表单
- 表单form
- form表单
- form表单
- form表单
- 表单(form)
- 表单form
- form 表单
- form表单
- [表单]form
- Form 表单
- form表单
- the NullPointerException when using getLastKnowLocation issue
- std::setw(size)与std::setfill(char)
- wifi驱动移植,arm9上 ifconfig ra0 up 失败
- EL表达式的隐式对象
- Nodejs连接mysql与models对应2
- rails 表单form
- C primer plus(第五版)编程练习第二章
- php中json_decode()和json_encode()的使用方法
- Android学习--隐式Intent
- 杭州电子科技大学ACM-1090
- springMVC中配置 snaker 工作流学习
- c++_常量存储
- Problem 1581 - Union of cubes+武大校赛+线段树维护
- 0-1背包问题与分数背包问题