LSform // dataEntryForm : set default value of displayed elements
authorBenjamin Renard <brenard@easter-eggs.com>
Mon, 18 Mar 2013 11:57:39 +0000 (12:57 +0100)
committerBenjamin Renard <brenard@easter-eggs.com>
Mon, 18 Mar 2013 11:57:39 +0000 (12:57 +0100)
public_html/includes/class/class.LSform.php

index 8462a64..3f7ea0e 100644 (file)
@@ -652,6 +652,17 @@ class LSform {
        }
        $this -> dataEntryForm       = $dataEntryForm;
        $this -> dataEntryFormConfig = $config;
+
+       // Set default value of displayed elements
+       if(is_array($config['defaultValues'])) {
+         foreach($config['displayedElements'] as $el) {
+           if (isset($config['defaultValues'][$el])) {
+             if (isset($this -> elements[$el])) {
+               $this -> elements[$el] -> setValueFromPostData($config['defaultValues'][$el]);
+             }
+           }
+         }
+       }
        return true;
      }
      LSerror :: addErrorCode('LSform_07',$dataEntryForm);