From 0a4ab845a5addfe9953464802315b78f1a1e1dbd Mon Sep 17 00:00:00 2001 From: Jackson Darlow Date: Tue, 11 May 2021 15:26:20 +1200 Subject: [PATCH] [#26] Disabled LinkField class's save logic --- src/LinkField.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/LinkField.php b/src/LinkField.php index fe25676..326bd1a 100644 --- a/src/LinkField.php +++ b/src/LinkField.php @@ -3,6 +3,7 @@ namespace gorriecoe\LinkField; use gorriecoe\Link\Models\Link; +use SilverStripe\ORM\DataObjectInterface; use SilverStripe\View\Requirements; use SilverStripe\Forms\FormField; use SilverStripe\Forms\CompositeField; @@ -239,4 +240,26 @@ public function getSortColumn() } return $this->config()->get('sort_column'); } + + /** + * We need this field to be considered a data field for request handing + * purposes, so we want to leave {@see FormField::hasData()} in tact, + * but we do not want to submit data + * + * @return bool + */ + public function canSubmitValue() + { + return false; + } + + /** + * This field acts as a container, so should not save data into the record + * + * @param DataObjectInterface $record + */ + public function saveInto(DataObjectInterface $record) + { + // noop + } }