Skip to content

Commit

Permalink
[elliot-sawyer#26] Disabled LinkField class's save logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jakxnz committed May 11, 2021
1 parent fdd3723 commit 0a4ab84
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/LinkField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
}
}

0 comments on commit 0a4ab84

Please sign in to comment.