Etemplate - change select multiple validation to also consider rows > 1 to enable multiple

This commit is contained in:
nathangray 2017-09-14 09:18:28 -06:00
parent ef50e36b49
commit 5b4fd418bf

View File

@ -129,6 +129,7 @@ class Select extends Etemplate\Widget
{
$form_name = self::form_name($cname, $this->id, $expand);
$widget_type = $this->attrs['type'] ? $this->attrs['type'] : $this->type;
$multiple = $this->attrs['multiple'] || $this->getElementAttribute($form_name, 'rows') > 1;
$ok = true;
if (!$this->is_readonly($cname, $form_name))
@ -147,7 +148,7 @@ class Select extends Etemplate\Widget
if ($child->type == 'option') $allowed[] = (string)$child->attrs['value'];
}
if (!$this->attrs['multiple'] || !($this->attrs['options'] > 1)) $allowed[] = '';
if (!$multiple ) $allowed[] = '';
foreach((array) $value as $val)
{
@ -198,7 +199,7 @@ class Select extends Etemplate\Widget
{
self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),'');
}
if (!$this->attrs['multiple'] && is_array($value) && count($value) > 1)
if (!$multiple && is_array($value) && count($value) > 1)
{
$value = array_shift($value);
}