From 275d733c22cff7cece6539916cf822497003777e Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 14 Nov 2014 12:38:40 +0000 Subject: [PATCH] fix customfield type "button" without any value stalls whole addressbook --- etemplate/js/et2_extension_customfields.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/etemplate/js/et2_extension_customfields.js b/etemplate/js/et2_extension_customfields.js index c55dec5da1..5dfbca67cb 100644 --- a/etemplate/js/et2_extension_customfields.js +++ b/etemplate/js/et2_extension_customfields.js @@ -503,21 +503,26 @@ var et2_customfields_list = et2_valueWidget.extend([et2_IDetachedDOM, et2_IInput attrs.label = field.label; + if (this._type == 'customfields-list') + { + // No buttons in a list, it causes problems with detached nodes + return false; + } // Simple case, one widget for a custom field - if(Object.keys(field.values).length == 1) + if(!field.values || typeof field.values != 'object' || Object.keys(field.values).length == 1) { for(var key in field.values) { attrs.label = key; attrs.onclick = field.values[key]; } + if (!attrs.label) + { + attrs.label = 'No "label=onclick" in values!'; + attrs.onclick = function(){ return false; }; + } return !attrs.readonly; } - else if (this._type == 'customfields-list') - { - // No buttons in a list, it causes problems with detached nodes - return false; - } else { // Complicated case, a single custom field you get multiple widgets