From 2923e55c712530241ba79bdbca1ca793ae003588 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 16 Aug 2012 09:48:54 +0200 Subject: [PATCH] BUG Restrict URLSegment preview to editable fields This fixes a bug where the Translatable module would have a duplicate preview because it had another ".urlsegment" field showing the value in its original language. See https://github.com/silverstripe/silverstripe-translatable/issues/43 --- javascript/SiteTreeURLSegmentField.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/javascript/SiteTreeURLSegmentField.js b/javascript/SiteTreeURLSegmentField.js index 1d1a6e8f..2605ac5a 100644 --- a/javascript/SiteTreeURLSegmentField.js +++ b/javascript/SiteTreeURLSegmentField.js @@ -11,9 +11,13 @@ * Constructor: onmatch */ onmatch : function() { - this._addActions(); // add elements and actions for editing - this.edit(); // toggle - this._autoInputWidth(); // set width of input field + // Only initialize the field if it contains an editable field. + // This ensures we don't get bogus previews on readonly fields. + if(this.find(':text').length) { + this._addActions(); // add elements and actions for editing + this.edit(); // toggle + this._autoInputWidth(); // set width of input field + } this._super(); },