Creates a password field, a masked text field that will hide the users input behind a mask character.
Options
- :disabled - If set to true, the user will not be able to use this input.
- :size - The number of visible characters that will fit in the input.
- :maxlength - The maximum number of characters that the browser will allow the user to enter.
- Any other key creates standard HTML attributes for the tag.
Examples
password_field_tag 'pass' # => <input name="pass" type="password" /> password_field_tag 'secret', 'Your secret here' # => <input name="secret" type="password" value="Your secret here" /> password_field_tag 'masked', nil, :class => 'masked_input_field' # => <input name="masked" type="password" /> password_field_tag 'token', '', :size => 15 # => <input name="token" size="15" type="password" value="" /> password_field_tag 'key', nil, :maxlength => 16 # => <input name="key" type="password" maxlength="16" /> password_field_tag 'confirm_pass', nil, :disabled => true # => <input name="confirm_pass" type="password" disabled="disabled" /> password_field_tag 'pin', '1234', :maxlength => 4, :size => 6, :class => "pin-input" # => <input name="pin" size="6" type="password" value="1234" maxlength="4" />
Source Code
# File action_view/helpers/form_tag_helper.rb, line 221 def password_field_tag(name = "password", value = nil, options = {}) text_field_tag(name, value, options.update("type" => "password")) end
<code/>and<pre/>for code samples.