From cf75387f561a24683dfc46bef3dfb9eb90b769fb Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 12 Oct 2011 20:56:11 +0000 Subject: [PATCH] Get custom selectbox options working --- etemplate/js/et2_extension_customfields.js | 7 ++++--- etemplate/js/et2_widget_selectbox.js | 9 +++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/etemplate/js/et2_extension_customfields.js b/etemplate/js/et2_extension_customfields.js index ea95415ccb..a26f0f1bb6 100644 --- a/etemplate/js/et2_extension_customfields.js +++ b/etemplate/js/et2_extension_customfields.js @@ -111,7 +111,7 @@ var et2_customfields_list = et2_DOMWidget.extend([et2_IDetachedDOM], { var attrs = { 'id': field_name, 'statustext': field.help, - 'required': field.needed + 'required': field.needed, }; if(this[setup_function]) { this[setup_function].call(this, field_name, field, attrs); @@ -129,6 +129,7 @@ var et2_customfields_list = et2_DOMWidget.extend([et2_IDetachedDOM], { .appendTo(row); this.rows[field_name] = cf[0]; } + // No label on the widget itself delete(attrs.label); @@ -204,7 +205,7 @@ var et2_customfields_list = et2_DOMWidget.extend([et2_IDetachedDOM], { attrs.size = field.len; }, _setup_select: function(field_name, field, attrs) { - attrs.sel_options = field.values; + attrs.select_options = field.values; }, /** @@ -228,7 +229,7 @@ var et2_customfields_list = et2_DOMWidget.extend([et2_IDetachedDOM], { var value = _values["value"][this.prefix + field_name] ? _values["value"][this.prefix + field_name] : null; if(this.widgets[field_name].implements( et2_IDetachedDOM)) { - widget_values = {"value": value}; + var widget_values = {"value": value}; this.widgets[field_name].setDetachedAttributes(this.widgets[field_name].getDetachedNodes(), widget_values); } else diff --git a/etemplate/js/et2_widget_selectbox.js b/etemplate/js/et2_widget_selectbox.js index 5c6a9dc3c7..4de68ebe2e 100644 --- a/etemplate/js/et2_widget_selectbox.js +++ b/etemplate/js/et2_widget_selectbox.js @@ -80,7 +80,12 @@ var et2_selectbox = et2_inputWidget.extend({ if(this.getArrayMgr("sel_options")) { var content_options = this.getArrayMgr("sel_options").getEntry(this.id); - if(content_options) _attrs["select_options"] = jQuery.merge(_attrs["select_options"],content_options); + if(_attrs["select_options"] && content_options) + { + _attrs["select_options"] = jQuery.merge(_attrs["select_options"],content_options); + } else if (content_options) { + _attrs["select_options"] = content_options; + } } // Check whether the options entry was found, if not read it from the @@ -105,7 +110,7 @@ var et2_selectbox = et2_inputWidget.extend({ var option = $j(document.createElement("option")) .attr("value", _value) - .text(_label); + .text(_label+""); if (typeof _title != "undefined" && _title) {