fix server-side validation to allow values of option children

This commit is contained in:
Ralf Becker 2016-04-21 14:51:40 +00:00
parent d8cf78d045
commit 9a57fbaedd

View File

@ -137,10 +137,16 @@ class Select extends Etemplate\Widget
$allowed2 = self::selOptions($form_name, true); // true = return array of option-values
$type_options = self::typeOptions($this,
// typeOptions thinks # of rows is the first thing in options
($this->attrs['rows'] && strpos($this->attrs['options'], $this->attrs['rows']) !== 0 ? $this->attrs['rows'].','.$this->attrs['options'] : $this->attrs['options']));
// typeOptions thinks # of rows is the first thing in options
($this->attrs['rows'] && strpos($this->attrs['options'], $this->attrs['rows']) !== 0 ? $this->attrs['rows'].','.$this->attrs['options'] : $this->attrs['options']));
$allowed = array_merge($allowed2,array_keys($type_options));
// add option children's values too, "" is not read, therefore we cast to string
foreach($this->children as $child)
{
if ($child->type == 'option') $allowed[] = (string)$child->attrs['value'];
}
if (!$this->attrs['multiple'] || !($this->attrs['options'] > 1)) $allowed[] = '';
foreach((array) $value as $val)