diff --git a/code/Forms/SiteTreeURLSegmentField.php b/code/Forms/SiteTreeURLSegmentField.php index ce169abf..bd26ca71 100644 --- a/code/Forms/SiteTreeURLSegmentField.php +++ b/code/Forms/SiteTreeURLSegmentField.php @@ -53,7 +53,7 @@ class SiteTreeURLSegmentField extends TextField parent::getAttributes(), [ 'data-prefix' => $this->getURLPrefix(), - 'data-suffix' => '?stage=Stage', + 'data-suffix' => $this->getURLSuffix(), 'data-default-url' => $this->getDefaultURL() ] ); diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index 98437b2c..ea189770 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -2027,6 +2027,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi $urlsegment = SiteTreeURLSegmentField::create("URLSegment", $this->fieldLabel('URLSegment')) ->setURLPrefix($baseLink) + ->setURLSuffix('?stage=Stage') ->setDefaultURL($this->generateURLSegment(_t( 'SilverStripe\\CMS\\Controllers\\CMSMain.NEWPAGE', 'New {pagetype}', diff --git a/tests/php/Forms/SiteTreeURLSegmentFieldTest.php b/tests/php/Forms/SiteTreeURLSegmentFieldTest.php new file mode 100644 index 00000000..c1f020b2 --- /dev/null +++ b/tests/php/Forms/SiteTreeURLSegmentFieldTest.php @@ -0,0 +1,31 @@ +setURLSuffix('?foo=bar'); + + $this->assertEquals('?foo=bar', $field->getURLSuffix()); + $this->assertEquals('?foo=bar', $field->getAttributes()['data-suffix']); + } +}