| 1 | package HTML::Widget::Element::Password; | ||
| 2 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | use base 'HTML::Widget::Element'; | ||
| 6 | |||
| 7 | __PACKAGE__->mk_accessors(qw/comment fill label value retain_default/); | ||
| 8 | __PACKAGE__->mk_attr_accessors(qw/size maxlength/); | ||
| 9 | |||
| 10 | =head1 NAME | ||
| 11 | |||
| 12 | HTML::Widget::Element::Password - Password Element | ||
| 13 | |||
| 14 | =head1 SYNOPSIS | ||
| 15 | |||
| 16 | my $e = $widget->element( 'Password', 'foo' ); | ||
| 17 | $e->comment('(Required)'); | ||
| 18 | $e->fill(1); | ||
| 19 | $e->label('Foo'); | ||
| 20 | $e->size(23); | ||
| 21 | $e->value('bar'); | ||
| 22 | |||
| 23 | =head1 DESCRIPTION | ||
| 24 | |||
| 25 | Password Element. | ||
| 26 | |||
| 27 | =head1 METHODS | ||
| 28 | |||
| 29 | =head2 retain_default | ||
| 30 | |||
| 31 | If true, overrides the default behaviour, so that after a field is missing | ||
| 32 | from the form submission, the xml output will contain the default value, | ||
| 33 | rather than be empty. | ||
| 34 | |||
| 35 | =head2 containerize | ||
| 36 | |||
| 37 | =cut | ||
| 38 | |||
| 39 | sub containerize { | ||
| 40 | my ( $self, $w, $value, $errors, $args ) = @_; | ||
| 41 | |||
| 42 | $value = ref $value eq 'ARRAY' ? shift @$value : $value; | ||
| 43 | |||
| 44 | $value = $self->value | ||
| 45 | if ( not defined $value ) | ||
| 46 | and $self->retain_default || not $args->{submitted}; | ||
| 47 | |||
| 48 | $value = undef unless $self->fill; | ||
| 49 | |||
| 50 | my $l = $self->mk_label( $w, $self->label, $self->comment, $errors ); | ||
| 51 | my $i = $self->mk_input( $w, { type => 'password', value => $value }, | ||
| 52 | $errors ); | ||
| 53 | my $e = $self->mk_error( $w, $errors ); | ||
| 54 | |||
| 55 | return $self->container( { element => $i, error => $e, label => $l } ); | ||
| 56 | } | ||
| 57 | |||
| 58 | =head1 SEE ALSO | ||
| 59 | |||
| 60 | L<HTML::Widget::Element> | ||
| 61 | |||
| 62 | =head1 AUTHOR | ||
| 63 | |||
| 64 | Sebastian Riedel, C<sri@oook.de> | ||
| 65 | |||
| 66 | =head1 LICENSE | ||
| 67 | |||
| 68 | This library is free software, you can redistribute it and/or modify it under | ||
| 69 | the same terms as Perl itself. | ||
| 70 | |||
| 71 | =cut | ||
| 72 | |||
| 73 | 1; |