reverting r52412, as it breaks not validating not send values, sending empty array for nothing selected in selectbox instead of (not submitted) null value

This commit is contained in:
Ralf Becker 2015-04-03 12:43:26 +00:00
parent 4ccc9b2cdb
commit d82f65e95e
4 changed files with 20 additions and 17 deletions

View File

@ -520,7 +520,7 @@ class etemplate_new extends etemplate_widget_template
{ {
if (!is_array($v) || !isset($old[$k]) || // no array or a new array if (!is_array($v) || !isset($old[$k]) || // no array or a new array
isset($v[0]) && !is_array($v[0]) && isset($v[count($v)-1]) || // or no associative array, eg. selecting multiple accounts isset($v[0]) && !is_array($v[0]) && isset($v[count($v)-1]) || // or no associative array, eg. selecting multiple accounts
is_array($v) && count($v) == 0 && is_array($old[$k])) // Empty array replacing non-empty is_array($v) && count($v) == 0) // Empty array replacing non-empty
{ {
$old[$k] = $v; $old[$k] = $v;
} }

View File

@ -213,9 +213,11 @@ class etemplate_widget_menupopup extends etemplate_widget
} }
} }
} }
if (isset($value))
self::set_array($validated, $form_name, $value); {
self::set_array($validated, $form_name, $value);
//error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value).', allowed='.array2string($allowed)); //error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value).', allowed='.array2string($allowed));
}
} }
else else
{ {

View File

@ -2394,7 +2394,7 @@ var et2_nextmatch_header_bar = et2_DOMWidget.extend(et2_INextmatchHeader,
} }
// Legacy: Add in 'All' option for cat_id, if not provided. // Legacy: Add in 'All' option for cat_id, if not provided.
if(name == 'cat_id' && options != null && (typeof options[''] == 'undefined' || options[0].value != '')) if(name == 'cat_id' && options != null && (typeof options[''] == 'undefined' || typeof options[0] != 'undefined' && options[0].value != ''))
{ {
widget_options.empty_label = this.egw().lang('All'); widget_options.empty_label = this.egw().lang('All');
} }

View File

@ -725,11 +725,12 @@ var et2_selectbox = et2_inputWidget.extend(
var value = []; var value = [];
jQuery("input:checked",this.multiOptions).each(function(){value.push(this.value);}); jQuery("input:checked",this.multiOptions).each(function(){value.push(this.value);});
// we need to return null for no value instead of empty array, which gets overwritten by preserved value on server-side // we need to return null for no value instead of empty array, which gets overwritten by preserved value on server-side
this.value = value.length > 0 ? value : null; this.value = value;
} }
else else
{ {
this.value = this._super.apply(this, arguments); this.value = this._super.apply(this, arguments);
if (this.value === null) this.value = []; // do NOT return null, as it does not get transmitted to server
} }
return this.value; return this.value;
}, },