File: edit_field_checkbox

package info (click to toggle)
libalzabo-perl 0.92-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,200 kB
  • sloc: perl: 15,060; makefile: 4
file content (63 lines) | stat: -r--r--r-- 1,101 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<%doc>
=pod

=head1 NAME

edit_field_checkbox

=head1 SYNOPSIS

  <& edit_field_checkbox, column => $column, row => $row &>

=head1 DESCRIPTION

Given a column and an optional row, this component produces a checkbox
form element for that column.  The value of this column when checked
is 1.

If a row is given, then its value will determine whether or not the
checkbox is checked.  Otherwise the column's default value will be
used.

=head1 PARAMETERS

=over 4


=item * column (required)

An C<Alzabo::Column> object.

=item * row (optional)

An Alzabo row object.

=item * class (optional)

This defaults to C<<
$m->base_comp->attr_if_exists('checkbox_class_default') >>.

=back

=cut
</%doc>
<input type="checkbox" name="<% $col_name %>" value="1" <% $true ? 'checked="checked"' : '' %> class="<% $class %>">\
<%args>
$column
$row => undef
$class => $m->base_comp->attr_if_exists('checkbox_class_default')
</%args>
<%init>
my $true;

my $col_name = ref $column ? $column->name : $column;

if (defined $row)
{
    $true = $row->select( $col_name );
}
else
{
    $true = $column->default;
}
</%init>