[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [1620] trunk/LedgerSMB/Template/Elements.pm



Revision: 1620
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1620&view=rev
Author:   tetragon
Date:     2007-09-16 12:52:27 -0700 (Sun, 16 Sep 2007)

Log Message:
-----------
A modified version of another patch from hunmonk

Modified Paths:
--------------
    trunk/LedgerSMB/Template/Elements.pm

Modified: trunk/LedgerSMB/Template/Elements.pm
===================================================================
--- trunk/LedgerSMB/Template/Elements.pm	2007-09-16 16:40:36 UTC (rev 1619)
+++ trunk/LedgerSMB/Template/Elements.pm	2007-09-16 19:52:27 UTC (rev 1620)
@@ -147,6 +147,7 @@
     attributes => { foo => 'bar' },
     values => [ '4', '', '3'],
     labels => [ 'Label one', '', 'Label three'],
+    default_values => [ 'checkbox_name1'],
     
 };
 
@@ -168,7 +169,7 @@
 
         # 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 @@
         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++;
     }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.