Skip to content
This repository
Browse code

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 silverstripe/silverstripe-translatable#43
  • Loading branch information...
commit 2923e55c712530241ba79bdbca1ca793ae003588 1 parent f5007a5
Ingo Schommer authored August 16, 2012

Showing 1 changed file with 7 additions and 3 deletions. Show diff stats Hide diff stats

  1. 10  javascript/SiteTreeURLSegmentField.js
10  javascript/SiteTreeURLSegmentField.js
@@ -11,9 +11,13 @@
11 11
 			 * Constructor: onmatch
12 12
 			 */
13 13
 			onmatch : function() {
14  
-				this._addActions(); // add elements and actions for editing
15  
-				this.edit(); // toggle
16  
-				this._autoInputWidth(); // set width of input field
  14
+				// Only initialize the field if it contains an editable field.
  15
+				// This ensures we don't get bogus previews on readonly fields.
  16
+				if(this.find(':text').length) {
  17
+					this._addActions(); // add elements and actions for editing
  18
+					this.edit(); // toggle
  19
+					this._autoInputWidth(); // set width of input field
  20
+				}
17 21
 				
18 22
 				this._super();
19 23
 			},

0 notes on commit 2923e55

Please sign in to comment.
Something went wrong with that request. Please try again.