Fix complex name finding to handle select options with label & value set, not just simple key => values

This commit is contained in:
nathangray 2018-10-09 10:20:16 -06:00
parent 2dd71574b4
commit cb902a3219

View File

@ -439,15 +439,20 @@ class Select extends Etemplate\Widget
} }
// Check for non-trivial name like a[b] // Check for non-trivial name like a[b]
$name_parts = explode('[',str_replace(array('[',']',']'),array('['),$name));
if(!$options) if(!$options)
{ {
$options = (array)self::get_array(self::$request->sel_options,$name); $options = (array)self::get_array(self::$request->sel_options,$name);
if(is_numeric(end($name_parts)) && $options['label'] && $options['value'])
{
// Too deep, we got a single option
$options = array();
}
} }
// Check for base of name in root of sel_options // Check for base of name in root of sel_options
if(!$options) if(!$options)
{ {
$name_parts = explode('[',str_replace(array('[',']',']'),array('['),$name));
if (count($name_parts)) if (count($name_parts))
{ {
$org_name = $name_parts[count($name_parts)-1]; $org_name = $name_parts[count($name_parts)-1];