[Solar-svn] Revision 3087

pmjones at solarphp.com pmjones at solarphp.com
Thu Apr 10 09:08:57 CDT 2008


Solar_Form_Load_Model: [FIX] Better setting of default values.  Previously, if a column (e.g. a calculated col) was not in the model but asked for in the form, you'd get a notice about it.  This just sets a null value instead.


Modified: trunk/Solar/Form/Load/Model.php
===================================================================
--- trunk/Solar/Form/Load/Model.php	2008-04-10 14:05:39 UTC (rev 3086)
+++ trunk/Solar/Form/Load/Model.php	2008-04-10 14:08:52 UTC (rev 3087)
@@ -76,8 +76,8 @@
             settype($list, 'array');
         }
         
-        // default values
-        $default = $model->fetchNew();
+        // default values as an array
+        $default = $model->fetchNew()->toArray();
         
         // loop through the list of requested columns and collect elements
         $elements = array();
@@ -103,13 +103,18 @@
                 );
             }
             
+            // default value
+            $defval = array_key_exists($name, $default)
+                    ? $default[$name]
+                    : null;
+            
             // initial set of element info based on the model column
             $base = array(
                 'name'    => $array_name . '[' . $name . ']',
                 'type'    => null,
                 'label'   => $model->locale(strtoupper("LABEL_$name")),
                 'descr'   => $model->locale(strtoupper("DESCR_$name")),
-                'value'   => $default[$name],
+                'value'   => $defval,
                 'require' => $cols[$name]['require'],
                 'disable' => $cols[$name]['primary'],
                 'options' => array(),




More information about the Solar-svn mailing list