rails text_field/text_area/hidden_field/password_field
来源:互联网 发布:nginx 多个域名 ssl 编辑:程序博客网 时间:2024/06/07 12:50
1.text_field
------------------------- ActionView::Helpers::FormHelper#text_field
text_field(object_name, method, options = {})
--------------------------------------------------------------------
Returns an input tag of the "text" type tailored for accessing a specified attribute (identified by method) on an object assigned to the template (identified by object). Additional options on the input tag can be passed as a hash with options.
Examples (call, result):
text_field("post", "title", "size" => 20)
<input type="text" id="post_title" name="post[title]" size="20" value="#{@post.title}" />
2.text_area
Returns a textarea opening and closing tag set tailored for accessing a specified attribute (identified bymethod) on an object assigned to the template (identified byobject). Additional options on the input tag can be passed as a hash withoptions.
Examples
text_area(:post, :body, :cols => 20, :rows => 40) # => <textarea cols="20" rows="40" id="post_body" name="post[body]"> # #{@post.body} # </textarea> text_area(:comment, :text, :size => "20x30") # => <textarea cols="20" rows="30" id="comment_text" name="comment[text]"> # #{@comment.text} # </textarea> text_area(:application, :notes, :cols => 40, :rows => 15, :class => 'app_input') # => <textarea cols="40" rows="15" id="application_notes" name="application[notes]" class="app_input"> # #{@application.notes} # </textarea> text_area(:entry, :body, :size => "20x20", :disabled => 'disabled') # => <textarea cols="20" rows="20" id="entry_body" name="entry[body]" disabled="disabled"> # #{@entry.body} # </textarea>
3.hidden_field
Returns a hidden input tag tailored for accessing a specified attribute (identified bymethod) on an object assigned to the template (identified byobject). Additional options on the input tag can be passed as a hash withoptions. These options will be tagged onto the HTML as an HTML element attribute as in the example shown.
Examples
hidden_field(:signup, :pass_confirm) # => <input type="hidden" id="signup_pass_confirm" name="signup[pass_confirm]" value="#{@signup.pass_confirm}" /> hidden_field(:post, :tag_list) # => <input type="hidden" id="post_tag_list" name="post[tag_list]" value="#{@post.tag_list}" /> hidden_field(:user, :token) # => <input type="hidden" id="user_token" name="user[token]" value="#{@user.token}" />
4.password_field(object_name, method, options = {})Returns an input tag of the "password" type tailored for accessing a specified attribute (identified by method) on an object assigned to the template (identified by object). Additional options on the input tag can be passed as a hash with options. These options will be tagged onto the HTML as an HTML element attribute as in the example shown.
Examples
password_field(:login, :pass, :size => 20) # => <input type="text" id="login_pass" name="login[pass]" size="20" value="#{@login.pass}" /> password_field(:account, :secret, :class => "form_input") # => <input type="text" id="account_secret" name="account[secret]" value="#{@account.secret}" class="form_input" /> password_field(:user, :password, :onchange => "if $('user[password]').length > 30 { alert('Your password needs to be shorter!'); }") # => <input type="text" id="user_password" name="user[password]" value="#{@user.password}" onchange = "if $('user[password]').length > 30 { alert('Your password needs to be shorter!'); }"/> password_field(:account, :pin, :size => 20, :class => 'form_input') # => <input type="text" id="account_pin" name="account[pin]" size="20" value="#{@account.pin}" class="form_input" />___________________________________________________________
转自:http://blog.csdn.net/linda_cai/article/details/2093498
- rails text_field/text_area/hidden_field/password_field
- rails text_field/text_area/hidden_field/password_field
- hidden_field_tag and hidden_field
- ruby text_area大小
- text_area限定字数
- Rails
- Rails
- Rails
- rails
- Rails
- rails
- Rails
- Rails
- Rails
- Rails
- Rails
- Rails
- Rails
- ListView 输入法框遮挡内容
- GitHub和SourceTree入门教程
- 状态模式和策略模式比较
- C#学习笔记-方法和修饰符
- 增加最少的边使有向图变为强连通图
- rails text_field/text_area/hidden_field/password_field
- CSS绘制三角形的原理剖析
- poj 3140 Contestants Division (树形dp)
- android之Service(3)Bound Service
- Freemarker 小技巧
- jfinal后台控制跳转方式
- mysql 10061
- 大数据分析工具-Splunk介绍
- 国内外最全的asp.net开源项目