diff --git a/etemplate/inc/class.etemplate_widget_nextmatch_customfilter.inc.php b/etemplate/inc/class.etemplate_widget_nextmatch_customfilter.inc.php new file mode 100644 index 0000000000..2276b4f819 --- /dev/null +++ b/etemplate/inc/class.etemplate_widget_nextmatch_customfilter.inc.php @@ -0,0 +1,37 @@ +sel_options to be used on the client + * + * @param string $cname + */ + public function beforeSendToClient($cname) + { + self::$transformation['type'] = $this->attrs['type']; + $form_name = self::form_name($cname, $this->id, $expand); + $this->setElementAttribute($form_name, 'options', $this->attrs['options']); + + return parent::beforeSendToClient($cname); + } +} diff --git a/etemplate/js/et2_core_widget.js b/etemplate/js/et2_core_widget.js index f5a86b63c2..5a69bc892c 100644 --- a/etemplate/js/et2_core_widget.js +++ b/etemplate/js/et2_core_widget.js @@ -57,7 +57,7 @@ function et2_register_widget(_constructor, _types) * @param _name is the name of the widget with which it is registered. If the * widget is not found, an et2_placeholder will be created. * @param _attrs is an associative array with attributes. If not passed, it will - * default to true. + * default to an empty object. * @param _parent is the parent to which the element will be attached. If _parent * is not passed, it will default to null. Then you have to attach the element * to a parent using the addChild or insertChild method. @@ -183,10 +183,9 @@ var et2_widget = Class.extend({ this.id = _attrs["id"]; // Add this widget to the given parent widget - this._parent = _parent; if (_parent != null) { - this._parent.addChild(this); + _parent.addChild(this); } // The supported widget classes array defines a whitelist for all widget @@ -477,6 +476,13 @@ var et2_widget = Class.extend({ // Special handling for the legacy options if (attrName == "options" && _proto.legacyOptions.length > 0) { + // Check for modifications on legacy options here. Normal modifications + // are handled in widget constructor, but it's too late for legacy options then + if(_target.id && this.getArrayMgr("modifications").getEntry(_target.id)) + { + var mod = this.getArrayMgr("modifications").getEntry(_target.id); + if(mod.options) attrValue = _attrsObj[i].value = mod.options; + } // Check for entire legacy options passed in content if(attrValue.charAt(0) == '@' && attrValue.indexOf(',') == -1) { diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index d48a162f0c..7984f7d469 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -1702,8 +1702,13 @@ var et2_nextmatch_customfilter = et2_nextmatch_filterheader.extend({ "type": "string", "description": "The actual type of widget you should use" }, + "widget_options": { + "name": "Actual options", + "type": "any", + "description": "The options for the actual widget" + }, }, - legacyOptions: ["widget_type"], + legacyOptions: ["widget_type","widget_options"], real_node: null, @@ -1720,7 +1725,7 @@ var et2_nextmatch_customfilter = et2_nextmatch_filterheader.extend({ } // Avoid warning about non-existant attribute delete(_attrs.widget_type); - this.real_node = et2_createWidget(_attrs.type, _attrs, this._parent); + this.real_node = et2_createWidget(_attrs.type, _attrs.widget_options, this._parent); }, // Just pass the real DOM node through, in case anybody asks diff --git a/etemplate/js/et2_widget_date.js b/etemplate/js/et2_widget_date.js index f115c1ca28..2cc4b38446 100644 --- a/etemplate/js/et2_widget_date.js +++ b/etemplate/js/et2_widget_date.js @@ -416,7 +416,7 @@ var et2_date_duration = et2_date.extend({ var value = this.duration.val(); if(value === '') { - return this.options.empty_not_0 ? null : ''; + return this.options.empty_not_0 ? null : 0; } // Put value into minutes for further processing switch(this.format ? this.format.val() : this.options.display_format) diff --git a/etemplate/js/et2_widget_selectbox.js b/etemplate/js/et2_widget_selectbox.js index 5d988c4e93..5f2608ca21 100644 --- a/etemplate/js/et2_widget_selectbox.js +++ b/etemplate/js/et2_widget_selectbox.js @@ -55,10 +55,15 @@ var et2_selectbox = et2_inputWidget.extend({ }, "value": { "type": "any" // Can be string or integer + }, + // Type specific legacy options. Avoid using. + "other": { + "ignore": true, + "type": "any" } }, - legacyOptions: ["rows"], + legacyOptions: ["rows","other"], // Other is sub-type specific init: function() { this._super.apply(this, arguments); @@ -159,6 +164,10 @@ var et2_selectbox = et2_inputWidget.extend({ { var row_id = this.id.replace(/[0-9]+/,row_stuck[i]); content_options = this.getArrayMgr("sel_options").getEntry(row_id); + if(!content_options || content_options.length == 0) + { + content_options = this.getArrayMgr("sel_options").getEntry(row_stuck[i] + '[' + this.id + ']'); + } } } if(_attrs["select_options"] && content_options) diff --git a/etemplate/js/et2_widget_tree.js b/etemplate/js/et2_widget_tree.js index ed8fa963ea..6b4898ead0 100644 --- a/etemplate/js/et2_widget_tree.js +++ b/etemplate/js/et2_widget_tree.js @@ -171,6 +171,7 @@ var et2_tree = et2_inputWidget.extend({ } var parent_id = parseInt(options[key]['parent']); + if(isNaN(parent_id)) parent_id = 0; if(!stack[parent_id]) stack[parent_id] = []; stack[parent_id].push(options[key]); }