From 9a57fbaeddf5aed7c4ad9f7d53f1484e99e4fa7d Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 21 Apr 2016 14:51:40 +0000 Subject: [PATCH] fix server-side validation to allow values of option children --- api/src/Etemplate/Widget/Select.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api/src/Etemplate/Widget/Select.php b/api/src/Etemplate/Widget/Select.php index 11a929d956..83a1de8e91 100644 --- a/api/src/Etemplate/Widget/Select.php +++ b/api/src/Etemplate/Widget/Select.php @@ -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)