public function saveInto(DataObjectInterface $record) { if ($record->hasField($this->name) && $record->escapeTypeForField($this->name) != 'xml') { throw new Exception('HTMLEditorField->saveInto(): This field should save into a HTMLText or HTMLVarchar field.'); } // Sanitise if requested $htmlValue = Injector::inst()->create('HTMLValue', $this->Value()); if ($this->config()->sanitise_server_side) { $santiser = Injector::inst()->create('HTMLEditorSanitiser', HTMLEditorConfig::get_active()); $santiser->sanitise($htmlValue); } // optionally manipulate the HTML after a TinyMCE edit and prior to a save $this->extend('processHTML', $htmlValue); // Store into record $record->{$this->name} = $htmlValue->getContent(); }
/** * Save the current value of this MultiSelectField into a DataObject. * If the field it is saving to is a has_many or many_many relationship, * it is saved by setByIDList(), otherwise it creates a comma separated * list for a standard DB text/varchar field. * * @param DataObject|DataObjectInterface $record The record to save into */ public function saveInto(DataObjectInterface $record) { $fieldName = $this->getName(); if (empty($fieldName) || empty($record)) { return; } $relation = $record->hasMethod($fieldName) ? $record->{$fieldName}() : null; // Detect DB relation or field $items = $this->getValueArray(); if ($relation instanceof Relation) { // Save ids into relation $relation->setByIDList($items); } elseif ($record->hasField($fieldName)) { // Save dataValue into field $record->{$fieldName} = $this->stringEncode($items); } }