| 1 | use warnings; | ||
| 2 | use strict; | ||
| 3 | |||
| 4 | package Jifty::Web::Form::Field::Password; | ||
| 5 | |||
| 6 | use base qw/Jifty::Web::Form::Field/; | ||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | Jifty::Web::Form::Field::Password - Add a password field to your forms | ||
| 11 | |||
| 12 | =head1 METHODS | ||
| 13 | |||
| 14 | =head2 type | ||
| 15 | |||
| 16 | The HTML input type is C<password>. | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | sub type { 'password' } | ||
| 21 | |||
| 22 | =head2 current_value | ||
| 23 | |||
| 24 | The default value of a password field should B<always> be empty. | ||
| 25 | |||
| 26 | =cut | ||
| 27 | |||
| 28 | sub current_value {''} | ||
| 29 | |||
| 30 | =head2 other_widget_properties | ||
| 31 | |||
| 32 | No browser-based form auto-completion in password fields ;) | ||
| 33 | |||
| 34 | Note: This has nothing to do with Jifty's Autocomplete mechanism. | ||
| 35 | |||
| 36 | =cut | ||
| 37 | |||
| 38 | sub other_widget_properties { | ||
| 39 | return q{autocomplete="off"}; | ||
| 40 | } | ||
| 41 | |||
| 42 | =head2 render_value | ||
| 43 | |||
| 44 | Never render a value for a password | ||
| 45 | |||
| 46 | =cut | ||
| 47 | |||
| 48 | |||
| 49 | sub render_value { | ||
| 50 | Jifty->web->out('-'); | ||
| 51 | return ''; | ||
| 52 | } | ||
| 53 | |||
| 54 | =head2 classes | ||
| 55 | |||
| 56 | Output password fields with the class 'password' | ||
| 57 | |||
| 58 | =cut | ||
| 59 | |||
| 60 | sub classes { | ||
| 61 | my $self = shift; | ||
| 62 | return join(' ', 'password', ($self->SUPER::classes)); | ||
| 63 | } | ||
| 64 | |||
| 65 | 1; |