From acd6e1f4ea8744e3ba87a1dab47aa41164422890 Mon Sep 17 00:00:00 2001 From: tetragon Date: Sun, 16 Sep 2007 16:40:36 +0000 Subject: 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 --- LedgerSMB/Template/Elements.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'LedgerSMB/Template/Elements.pm') 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++; } -- cgit v1.2.3