mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 00:13:35 +01:00
fixed not working custom fields of type radio
This commit is contained in:
parent
e63984884f
commit
15fbd6bde8
@ -58,7 +58,8 @@ class etemplate_widget_checkbox extends etemplate_widget
|
||||
{
|
||||
self::set_validation_error($form_name,lang('Field must not be empty !!!'),'');
|
||||
}
|
||||
$value_attr = $this->type == 'radio' ? 'set_value' : 'selected_value';
|
||||
$type = $this->type ? $this->type : $this->attrs['type'];
|
||||
$value_attr = $type == 'radio' ? 'set_value' : 'selected_value';
|
||||
// defaults for set and unset values
|
||||
if (!$this->attrs[$value_attr] && !$this->attrs['unselected_value'])
|
||||
{
|
||||
@ -71,7 +72,19 @@ class etemplate_widget_checkbox extends etemplate_widget
|
||||
$selected_value = self::expand_name($this->attrs[$value_attr], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'],$expand['cont']);
|
||||
$unselected_value = self::expand_name($this->attrs['unselected_value'], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'],$expand['cont']);
|
||||
}
|
||||
if (in_array((string)$selected_value, (array)$value))
|
||||
if ($type == 'radio')
|
||||
{
|
||||
$options = etemplate_widget_menupopup::selOptions($form_name, true);
|
||||
if (in_array($value, $options))
|
||||
{
|
||||
$valid = $value;
|
||||
}
|
||||
elseif (!isset($valid))
|
||||
{
|
||||
$valid = ''; // do not overwrite value of an other radio-button of the same group (identical name)!
|
||||
}
|
||||
}
|
||||
elseif (in_array((string)$selected_value, (array)$value))
|
||||
{
|
||||
if ($multiple)
|
||||
{
|
||||
@ -83,10 +96,6 @@ class etemplate_widget_checkbox extends etemplate_widget
|
||||
$valid = $selected_value;
|
||||
}
|
||||
}
|
||||
elseif ($this->type == 'radio')
|
||||
{
|
||||
if (!isset($valid)) $valid = ''; // do not overwrite value of an other radio-button of the same group (identical name)!
|
||||
}
|
||||
else // if checkbox is not checked, html returns nothing: eTemplate returns unselected_value (default false)
|
||||
{
|
||||
if ($multiple)
|
||||
|
@ -306,6 +306,8 @@ class etemplate_widget_customfields extends etemplate_widget_transformer
|
||||
if (!$this->is_readonly($cname, $form_name))
|
||||
{
|
||||
$value_in = self::get_array($content, $form_name);
|
||||
// if we have no id / use self::GLOBAL_ID, we have to set $value_in in global namespace for regular widgets validation to find
|
||||
if (!$this->id) $content = array_merge($content, $value_in);
|
||||
//error_log(__METHOD__."($cname, ...) form_name=$form_name, use-private={$this->attrs['use-private']}, value_in=".array2string($value_in));
|
||||
$customfields =& $this->getElementAttribute(self::GLOBAL_VALS, 'customfields');
|
||||
if(is_array($value_in))
|
||||
|
@ -318,6 +318,13 @@ var et2_radioGroup = et2_valueWidget.extend([et2_IDetachedDOM],
|
||||
* @param {object} _options object with value: label pairs
|
||||
*/
|
||||
set_options: function(_options) {
|
||||
// Call the destructor of all children
|
||||
for (var i = this._children.length - 1; i >= 0; i--)
|
||||
{
|
||||
this._children[i].free();
|
||||
}
|
||||
this._children = [];
|
||||
// create radio buttons for each option
|
||||
for(var key in _options)
|
||||
{
|
||||
var attrs = {
|
||||
|
Loading…
Reference in New Issue
Block a user