public function saveInto(\DataObjectInterface $record) { $fieldname = $this->name; $relation = $fieldname && $record && $record->hasMethod($fieldname) ? $record->{$fieldname}() : null; $value = $this->dataValue(); if ($relation) { // TODO: Save to relation } else { if (is_array($value)) { $this->value = json_encode(array_values($value)); } } parent::saveInto($record); }
/** * Only save if field was shown on the client, and is not empty. * * @param DataObjectInterface $record * * @return boolean */ public function saveInto(DataObjectInterface $record) { if (!$this->isSaveable()) { return false; } if (!($this->canBeEmpty && !$this->value)) { parent::saveInto($record); } }
public function saveInto(\DataObjectInterface $record) { $v = $this->Value(); // if (is_array($v)) { $allItems = array(); foreach ($this->children as $field) { $fieldname = $field->getName(); if (strpos($fieldname, '__') > 0) { $bits = array_reverse(explode('__', $fieldname)); if (count($bits) > 3) { list($dataFieldName, $id, $classname) = $bits; if (!isset($allItems["{$classname}-{$id}"])) { $item = $this->records->filter(array('ClassName' => $classname, 'ID' => $id))->first(); $allItems["{$classname}-{$id}"] = $item; } $item = $allItems["{$classname}-{$id}"]; if ($item) { if ($field) { $field->setName($dataFieldName); $field->saveInto($item); } } } } } foreach ($allItems as $item) { $item->write(); } parent::saveInto($record); }
/** * Only save if field was shown on the client, * and is not empty. * * @param DataObject $record * @return bool */ function saveInto(DataObject $record) { if(!$this->isSaveable()) return false; if(!($this->canBeEmpty && !$this->value)) { parent::saveInto($record); } }