Skip to content

Commit

Permalink
Merge branch 'pull/322'
Browse files Browse the repository at this point in the history
  • Loading branch information
dhensby committed Oct 11, 2017
2 parents 0157bd0 + 1dcba49 commit 7bf430b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/Forms/SubsitesTreeDropdownField.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\TreeDropdownField;
use SilverStripe\View\Requirements;
use SilverStripe\Subsites\State\SubsiteState;

/**
* Wraps around a TreedropdownField to add ability for temporary
Expand Down Expand Up @@ -52,14 +53,10 @@ public function getSubsiteID()

public function tree(HTTPRequest $request)
{
$session = Controller::curr()->getRequest()->getSession();

$oldSubsiteID = $session->get('SubsiteID');
$session->set('SubsiteID', $this->subsiteID);

$results = parent::tree($request);

$session->set('SubsiteID', $oldSubsiteID);
$results = SubsiteState::singleton()->withState(function () use ($request) {
SubsiteState::singleton()->setSubsiteId($this->subsiteID);
return parent::tree($request);
});

return $results;
}
Expand Down

0 comments on commit 7bf430b

Please sign in to comment.