%doc>
A tristate checkbox (with three values: true, false, and null).
Internally, this creates a checkbox, coupled via javascript to a hidden
field that actually contains the value. For now, the only values these
can have are 1, -1, and empty. Clicking the checkbox cycles between them.
For compatibility with regular checkboxes, empty is the false state and
-1 is the indeterminate state.
Displaying these is a problem. "indeterminate" is a standard HTML5 attribute
but some browsers display it in unhelpful ways (e.g. Firefox slightly grays
the checkbox, approximately #dddddd), and checkboxes ignore nearly all CSS
styling.
%doc>
<%shared>
my $init = 0;
%shared>
% if ( !$init ) {
% $init = 1;
% } # end of $init
<%init>
my %opt = @_;
# might be useful but I'm not implementing it yet
#my $onchange = $opt{'onchange'}
# ? 'onChange="'. $opt{'onchange'}. '(this)"'
# : '';
$opt{'id'} ||= 'hidden_'.$opt{'field'};
my $curr_value = '-1';
if (exists $opt{curr_value}) {
$curr_value = $opt{curr_value};
$curr_value = '' unless $curr_value eq '-1' or $curr_value eq '1';
}
%init>