diff options
author | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-16 19:52:27 +0000 |
---|---|---|
committer | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-16 19:52:27 +0000 |
commit | a4cb9a8b35b93f096971829951a5c622d3e42746 (patch) | |
tree | b6ebf14e3db2f2dbc037f4785dab5b11d712ed7b /LedgerSMB/Template | |
parent | acd6e1f4ea8744e3ba87a1dab47aa41164422890 (diff) |
A modified version of another patch from hunmonk
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1620 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/Template')
-rw-r--r-- | LedgerSMB/Template/Elements.pm | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/LedgerSMB/Template/Elements.pm b/LedgerSMB/Template/Elements.pm index 4d0fde43..e111b646 100644 --- a/LedgerSMB/Template/Elements.pm +++ b/LedgerSMB/Template/Elements.pm @@ -147,6 +147,7 @@ my $checkboxes = { attributes => { foo => 'bar' }, values => [ '4', '', '3'], labels => [ 'Label one', '', 'Label three'], + default_values => [ 'checkbox_name1'], }; @@ -168,7 +169,7 @@ sub generate_checkbox_elements { # Additional attributes while ( my ($key, $value) = each(%$checkboxes) ) { - if ( $key !~ /^(names|values|labels|id|value|name)$/ ) { + if ( $key !~ /^(names|(default_)?values|labels|id|value|name)$/ ) { $element->{$key} = $value; } } @@ -186,6 +187,11 @@ sub generate_checkbox_elements { if ( $checkboxes->{labels}[$i] ) { $element->{label} = $checkboxes->{labels}[$i]; } + # Add checked attribute if the default value applies to this element. + if ( defined($checkboxes->{default_values}) && + grep {$_ eq $checkbox_name} @{$checkboxes->{default_values}}) { + $element->{checked} = 'checked'; + } push @$elements, $element; $i++; } |