예제 #1
0
 /**
  * Takes input from a form (already validated) and assigns the values to
  * the fields contained within this table.
  * 
  * Certain operations are performed before inserting. The field is checked
  * to see whether it is key or not, and date, image and file input fields
  * are handled automatically
  * @param vars - An array of key=>value pairs to assign to the fields
  * @access public
  */
 function assignFieldValues($vars)
 {
     $ret = true;
     /*assign field field values*/
     $fields = $this->fields();
     foreach ($fields as $field) {
         $field->initialise();
         if (!$field->auto()) {
             if (isset($vars[$field->name()]) && !isset($vars['delete_' . $field->name()])) {
                 $val = $vars[$field->name()];
                 $this->initialiseFieldValue($field, $val);
             } else {
                 $uploads = FileUtility::uploadFiles();
                 if (isset($vars['delete_' . $field->name()])) {
                     $this->initialiseFieldValue($field, '');
                 } else {
                     $val = ArrayUtility::getArrayValue($uploads, $field->name());
                 }
                 if ($val) {
                     $this->initialiseFieldValue($field, $val);
                 }
             }
         }
         $val = '';
     }
     return true;
 }