Skip to content

Commit

Permalink
Fix added cache key for TreeDropdownField cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Joe authored and Damian Mooyman committed May 16, 2017
1 parent 6869e45 commit 3927e7e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Forms/TreeDropdownField.php
Expand Up @@ -6,6 +6,7 @@
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Core\Convert;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\Hierarchy\Hierarchy;
use SilverStripe\ORM\Hierarchy\MarkedSet;
Expand Down Expand Up @@ -643,11 +644,13 @@ public function performReadonlyTransformation()

public function getSchemaStateDefaults()
{
$data = parent::getSchemaStateDefaults();
// Check label for field
$record = $this->Value() ? $this->objectForKey($this->Value()) : null;
$selectedlabel = null;

$data = parent::getSchemaStateDefaults();
// Ensure cache is keyed by last modified date of the underlying list
$data['data']['cacheKey'] = DataList::create($this->sourceObject)->max('LastEdited');
if ($record) {
$data['data']['valueObject'] = [
'id' => $record->getField($this->keyField),
Expand Down

0 comments on commit 3927e7e

Please sign in to comment.