diff options
author | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-16 16:40:36 +0000 |
---|---|---|
committer | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-16 16:40:36 +0000 |
commit | acd6e1f4ea8744e3ba87a1dab47aa41164422890 (patch) | |
tree | 6e8d10e3ffbfdefe056dbd93453c07ced253f01e /LedgerSMB/Template/Elements.pm | |
parent | 1781468582b9eac650f45c874134ed8a671bfdfe (diff) |
Adding a lightly modified patch from hunmonk
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1619 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/Template/Elements.pm')
-rw-r--r-- | LedgerSMB/Template/Elements.pm | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/LedgerSMB/Template/Elements.pm b/LedgerSMB/Template/Elements.pm index 53dfe373..4d0fde43 100644 --- a/LedgerSMB/Template/Elements.pm +++ b/LedgerSMB/Template/Elements.pm @@ -77,6 +77,7 @@ my $radios = { attributes => { foo => 'bar' }, values => [ '1', '2', '3'], labels => [ 'Label one', '', 'Label three'], + default_value => '2', }; =back @@ -97,7 +98,7 @@ sub generate_radio_elements { # copy all additional attributes while ( my ($key, $value) = each(%$radios) ) { - if ( $key !~ /^(values|labels|id|value)$/ ) { + if ( $key !~ /^(values|labels|id|(default_)?value)$/ ) { $element->{$key} = $value; } } @@ -113,6 +114,12 @@ sub generate_radio_elements { if ( $radios->{labels}[$i] ) { $element->{label} = $radios->{labels}[$i]; } + + # Add checked attribute if the default value applies to this element. + if ( defined($radios->{default_value}) && $radios->{default_value} eq $radio_value) { + $element->{checked} = 'checked'; + } + push @$elements, $element; $i++; } |