mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
BUG Honour URL suffix on URL Segment field
This commit is contained in:
parent
65b8cc3948
commit
31fa262475
@ -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()
|
||||
]
|
||||
);
|
||||
|
@ -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}',
|
||||
|
31
tests/php/Forms/SiteTreeURLSegmentFieldTest.php
Normal file
31
tests/php/Forms/SiteTreeURLSegmentFieldTest.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\CMS\BatchActions\CMSBatchAction_Archive;
|
||||
use SilverStripe\CMS\BatchActions\CMSBatchAction_Publish;
|
||||
use SilverStripe\CMS\BatchActions\CMSBatchAction_Restore;
|
||||
use SilverStripe\CMS\BatchActions\CMSBatchAction_Unpublish;
|
||||
use SilverStripe\CMS\Forms\SiteTreeURLSegmentField;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
|
||||
/**
|
||||
* Tests CMS Specific subclasses of {@see CMSBatchAction}
|
||||
*/
|
||||
class SiteTreeURLSegmentFieldTest extends SapphireTest
|
||||
{
|
||||
/**
|
||||
* Test which pages can be published via batch actions
|
||||
*/
|
||||
public function testURLSuffix()
|
||||
{
|
||||
$field = new SiteTreeURLSegmentField('URLSegment');
|
||||
$field->setURLSuffix('?foo=bar');
|
||||
|
||||
$this->assertEquals('?foo=bar', $field->getURLSuffix());
|
||||
$this->assertEquals('?foo=bar', $field->getAttributes()['data-suffix']);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user