Merge pull request #1426 from SilbinaryWolf/created-readonly-sitetreeurlsegmentfield

NEW: Added readonly version of SiteTreeURLSegmentField
This commit is contained in:
Daniel Hensby 2016-03-19 10:16:35 +00:00
commit e4a198401a
2 changed files with 28 additions and 3 deletions

View File

@ -133,4 +133,27 @@ class SiteTreeURLSegmentField extends TextField {
return Controller::join_links($this->getURLPrefix(), $this->Value(), $this->getURLSuffix()); 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;
}
} }

View File

@ -2,9 +2,11 @@
<a class="preview" href="$URL" target="_blank"> <a class="preview" href="$URL" target="_blank">
$URL $URL
</a> </a>
<button type="button" class="ss-ui-button ss-ui-button-small edit"> <% if not $IsReadonly %>
<% _t('URLSegmentField.Edit', 'Edit') %> <button type="button" class="ss-ui-button ss-ui-button-small edit">
</button> <% _t('URLSegmentField.Edit', 'Edit') %>
</button>
<% end_if %>
</div> </div>
<div class="edit-holder"> <div class="edit-holder">
<input $AttributesHTML /> <input $AttributesHTML />