diff --git a/code/forms/SiteTreeURLSegmentField.php b/code/forms/SiteTreeURLSegmentField.php index 0ea7d87c..3e4a63ea 100644 --- a/code/forms/SiteTreeURLSegmentField.php +++ b/code/forms/SiteTreeURLSegmentField.php @@ -133,4 +133,27 @@ class SiteTreeURLSegmentField extends TextField { return Controller::join_links($this->getURLPrefix(), $this->Value(), $this->getURLSuffix()); } + public function performReadonlyTransformation() { + $newInst = parent::performReadonlyTransformation(); + $newInst->helpText = $this->helpText; + $newInst->urlPrefix = $this->urlPrefix; + $newInst->urlSuffix = $this->urlSuffix; + $newInst->defaultUrl = $this->defaultUrl; + return $newInst; + } +} + + +/** + * Readonly version of a site tree URL segment field + * + * @package forms + * @subpackage fields-basic + */ +class SiteTreeURLSegmentField_Readonly extends SiteTreeURLSegmentField { + protected $readonly = true; + + public function performReadonlyTransformation() { + return clone $this; + } } diff --git a/templates/forms/SiteTreeURLSegmentField.ss b/templates/forms/SiteTreeURLSegmentField.ss index 57effe1f..c7fbfce9 100644 --- a/templates/forms/SiteTreeURLSegmentField.ss +++ b/templates/forms/SiteTreeURLSegmentField.ss @@ -2,9 +2,11 @@ $URL - + <% if not $IsReadonly %> + + <% end_if %>