/** * The transform function performs the actual transformation of the data and is called after * the loading of the data in the source model. * * @param \MUtil_Model_ModelAbstract $model The parent model * @param array $data Nested array * @param boolean $new True when loading a new item * @param boolean $isPostData With post data, unselected multiOptions values are not set so should be added * @return array Nested array containing (optionally) transformed data */ public function transformLoad(\MUtil_Model_ModelAbstract $model, array $data, $new = false, $isPostData = false) { if ($isPostData) { return $data; } $empty = false; foreach ($data as $key => $row) { if (isset($row[$this->respTrackIdField]) && $row[$this->respTrackIdField]) { $fields = $this->fieldsDefinition->getFieldsDataFor($row[$this->respTrackIdField]); } else { if (!$empty) { $empty = array_fill_keys(array_keys($this->fieldsDefinition->getFieldNames()), null); } $fields = $empty; } //$data[$key] = array_merge($row, $fields); $data[$key] = array_replace($row, $fields); //$data[$key] = $row $fields; } return $data; }
/** * Returns an array of the fields in this track * key / value are id / field name * * @return array fieldid => fieldcode */ public function getFieldNames() { return $this->_fieldsDefinition->getFieldNames(); }