diff --git a/etemplate/inc/class.etemplate_widget_entry.inc.php b/etemplate/inc/class.etemplate_widget_entry.inc.php index e9e04ecd06..6435737ee8 100644 --- a/etemplate/inc/class.etemplate_widget_entry.inc.php +++ b/etemplate/inc/class.etemplate_widget_entry.inc.php @@ -66,10 +66,10 @@ abstract class etemplate_widget_entry extends etemplate_widget_transformer $attrs['id'] = $this->id; $form_name = self::form_name($cname, $this->id); - $data_id = $this->value ? self::form_name($cname, $this->value) : self::form_name($cname, self::ID_PREFIX . $this->id); - + $data_id = $attrs['value'] ? self::form_name($cname, $attrs['value']) : self::form_name($cname, self::ID_PREFIX . $this->id); + // No need to proceed - if(!$this->id) return; + if(!$data_id) return; // Find out which record to load $value = self::get_array(self::$request->content, $form_name, false, true); @@ -89,7 +89,7 @@ abstract class etemplate_widget_entry extends etemplate_widget_transformer // Check for conflict - more than one with same id/field and different type if($old_type && $old_type != $this->type) { - self::set_validation_error($this->id, lang('%1, duplicate ID', $this)); + //self::set_validation_error($this->id, lang('%1, duplicate ID', $this)); } } diff --git a/etemplate/js/et2_widget_entry.js b/etemplate/js/et2_widget_entry.js index 4b5e3e20ee..6c1f313f18 100644 --- a/etemplate/js/et2_widget_entry.js +++ b/etemplate/js/et2_widget_entry.js @@ -71,13 +71,20 @@ var et2_entry = et2_valueWidget.extend( */ init: function(parent, attrs) { // Often the ID conflicts, so check prefix - if(attrs.id && attrs.id.indexOf(this.prefix) < 0 && typeof attrs.value == 'undefined') + if(attrs.id && attrs.id.indexOf(this.prefix) < 0) { attrs.id = this.prefix + attrs.id; } + var value = attrs.value; this._super.apply(this, arguments); + // Save value from parsing, but only if set + if(value) + { + this.options.value = value; + } + this.widget = null; this.setDOMNode(document.createElement('span')); }, @@ -108,9 +115,15 @@ var et2_entry = et2_valueWidget.extend( }; var widget = et2_createWidget(attrs.type, attrs, this); + // If value is not set, etemplate takes care of everything + // If value was set, find the record explicitly. + if(typeof this.options.value == 'string') + { + widget.options.value = this.getRoot().getArrayMgr('content').getEntry(this.prefix+this.options.value + '['+this.options.field+']'); + } if(this.options.compare) { - widget.options.value = this.getArrayMgr('content').getEntry(this.options.field) == this.options.compare ? 'X' : ''; + widget.options.value = widget.options.value == this.options.compare ? 'X' : ''; } if(this.options.alternate_fields) {