public Method

FormHelper.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 name="login[pass]" size="20" type="text" value="#{@login.pass}" />

password_field(:account, :secret, :class => "form_input")
# => <input name="account[secret]" type="text" value="#{@account.secret}" />

password_field(:user, :password, :onchange => "if $('user[password]').length > 30 { alert('Your password needs to be shorter!'); }")
# => <input name="user[password]" type="text" 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 name="account[pin]" size="20" type="text" value="#{@account.pin}" />

Source Code

# File action_view/helpers/form_helper.rb, line 329
def password_field(object_name, method, options = {})
  InstanceTag.new(object_name, method, self, nil, options.delete(:object)).to_input_field_tag("password", options)
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.