diff --git a/etemplate/inc/class.etemplate_new.inc.php b/etemplate/inc/class.etemplate_new.inc.php index a825d8b3f4..d8f0ea314c 100644 --- a/etemplate/inc/class.etemplate_new.inc.php +++ b/etemplate/inc/class.etemplate_new.inc.php @@ -109,7 +109,7 @@ class etemplate_new 'sel_options' => $sel_options, 'readonlys' => $readonlys, 'modifications' => $this->modifications, - 'validation_errros' => self::$validation_errors, + 'validation_errors' => self::$validation_errors, )).'); '; diff --git a/etemplate/js/et2_inputWidget.js b/etemplate/js/et2_inputWidget.js index 4664bf2068..dbd18e5669 100644 --- a/etemplate/js/et2_inputWidget.js +++ b/etemplate/js/et2_inputWidget.js @@ -60,6 +60,21 @@ var et2_inputWidget = et2_baseWidget.extend(et2_IInput, { this._oldValue = ""; }, + loadingFinished: function() { + this._super.call(this, arguments); + + if (this.id != "") + { + // Set the value for this element + var contentMgr = this.getArrayMgr("content"); + var val = contentMgr.getValueForID(this.id); + if (val !== null) + { + this.set_value(val); + } + } + }, + set_value: function(_value) { this._oldValue = _value; @@ -73,7 +88,8 @@ var et2_inputWidget = et2_baseWidget.extend(et2_IInput, { set_id: function(_value) { this.id = _value; - // Set the id of the input node + // Set the id of the _input_ node (in contrast to the default + // implementation, which sets the base node) var node = this.getInputNode(); if (node) { @@ -86,17 +102,6 @@ var et2_inputWidget = et2_baseWidget.extend(et2_IInput, { node.removeAttribute("id"); } } - - // Set the value for this element - var mgr = this.getArrayMgr("content"); - if (_value != '' && mgr != null) - { - var val = mgr.getValueForID(this.id); - if (val !== null) - { - this.set_value(val); - } - } }, get_value: function() { diff --git a/etemplate/js/et2_widget.js b/etemplate/js/et2_widget.js index 0900ca121a..f0b6f9d4d4 100644 --- a/etemplate/js/et2_widget.js +++ b/etemplate/js/et2_widget.js @@ -383,6 +383,9 @@ var et2_widget = Class.extend({ var widget = new constructor(this, _nodeName) widget.loadFromXML(_node); + // Call the "loadFinished" function of the widget + widget.loadingFinished(); + return widget; }, @@ -472,6 +475,14 @@ var et2_widget = Class.extend({ loadContent: function(_content) { }, + /** + * Called when loading of the widget from XML node is finished. This + * function can be used to load the data from the data arrays (content, + * readonlys, sel_options etc.) + */ + loadingFinished: function() { + }, + /** * Calls the setter of each property with its current value, calls the * update function of all child nodes. diff --git a/etemplate/js/etemplate2.js b/etemplate/js/etemplate2.js index efcb17c4c9..b3f7de3e3d 100644 --- a/etemplate/js/etemplate2.js +++ b/etemplate/js/etemplate2.js @@ -71,7 +71,7 @@ etemplate2.prototype._createArrayManagers = function(_data) } // Create all neccessary _data entries - var neededEntries = ["content", "readonlys", "validation_errors"]; + var neededEntries = ["content", "sel_options", "readonlys", "modifications", "validation_errors"]; for (var i = 0; i < neededEntries.length; i++) { if (typeof _data[neededEntries[i]] == "undefined")