| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
=head1 NAME |
| 4 |
|
| 5 |
Debconf::Element::Web::Boolean - A check box on a form |
| 6 |
|
| 7 |
=cut |
| 8 |
|
| 9 |
package Debconf::Element::Web::Boolean; |
| 10 |
use warnings; |
| 11 |
use strict; |
| 12 |
use base qw(Debconf::Element); |
| 13 |
|
| 14 |
=head1 DESCRIPTION |
| 15 |
|
| 16 |
This element handles a check box on a web form. |
| 17 |
|
| 18 |
=head1 METHODS |
| 19 |
|
| 20 |
=over 4 |
| 21 |
|
| 22 |
=item show |
| 23 |
|
| 24 |
Generates and returns html representing the check box. |
| 25 |
|
| 26 |
=cut |
| 27 |
|
| 28 |
sub show { |
| 29 |
my $this=shift; |
| 30 |
|
| 31 |
$_=$this->question->extended_description; |
| 32 |
s/\n/\n<br>\n/g; |
| 33 |
$_.="\n<p>\n"; |
| 34 |
|
| 35 |
my $default=''; |
| 36 |
$default=$this->question->value if defined $this->question->value; |
| 37 |
my $id=$this->id; |
| 38 |
$_.="<input type=checkbox name=\"$id\"". ($default eq 'true' ? ' checked' : ''). ">\n<b>". |
| 39 |
$this->question->description."</b>"; |
| 40 |
|
| 41 |
return $_; |
| 42 |
} |
| 43 |
|
| 44 |
=item value |
| 45 |
|
| 46 |
Overridden to handle processing form input data. |
| 47 |
|
| 48 |
=cut |
| 49 |
|
| 50 |
sub value { |
| 51 |
my $this=shift; |
| 52 |
|
| 53 |
return $this->SUPER::value() unless @_; |
| 54 |
my $value=shift; |
| 55 |
$this->SUPER::value($value eq 'on' ? 'true' : 'false'); |
| 56 |
} |
| 57 |
|
| 58 |
=back |
| 59 |
|
| 60 |
=head1 AUTHOR |
| 61 |
|
| 62 |
Joey Hess <[email protected]> |
| 63 |
|
| 64 |
=cut |
| 65 |
|
| 66 |
1 |