fix select-dow widget to return again a single value by oring together selected week-days

This commit is contained in:
Ralf Becker 2013-11-06 08:49:06 +00:00
parent aeb6ebd84c
commit 2793ab44fd

View File

@ -14,10 +14,10 @@
/**
* eTemplate select widget
*
* @todo unavailable cats (eg. private cats of an other user) need to be preserved!
*/
class etemplate_widget_menupopup extends etemplate_widget
{
/**
* If the selectbox has this many rows, give it a search box automatically
*/
@ -105,6 +105,32 @@ class etemplate_widget_menupopup extends etemplate_widget
{
self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),'');
}
// some widgets sub-types need some post-processing
// ToDo: move it together with preprocessing to clientside
switch ($this->type['attr'])
{
case 'select-dow':
$dow = 0;
foreach((array)$value as $val)
{
$dow |= $val;
}
$value = $dow;
break;
case 'select-country':
$legacy_options = $this->attrs['rows'] && strpos($this->attrs['options'], $this->attrs['rows']) !== 0 ?
$this->attrs['rows'].','.$this->attrs['options'] : $this->attrs['options'];
list(,$country_use_name) = explode(',', $legacy_options);
if ($country_use_name && $value)
{
$value = $GLOBALS['egw']->country->get_full_name($value);
}
break;
case 'select-cat':
// ToDo: unavailable cats need to be merged in again
}
$valid =& self::get_array($validated, $form_name, true);
$valid = $value;
//error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value).', allowed='.array2string($allowed));
@ -315,7 +341,7 @@ class etemplate_widget_menupopup extends etemplate_widget
{
$options = $GLOBALS['egw']->country->countries();
}
if (($extension_data['country_use_name'] = $type) && $value)
if ($type && $value)
{
$value = $GLOBALS['egw']->country->country_code($value);
if (!isset($options[$value]))