[core] render two levels 'values' parameter property with optgroup

example:
$parameterSet=array(
  'feed'=>array(
     'name'=>'Feed',
     'type'=>'list',
     'values'=>array(
        'list A'=>array(
           'feed A1'=>'fA1',
           'feed A2'=>'fA2'
        ),
        'list B'=>array(
           'feed B1'=>'fB1',
           'feed B2'=>'fB2
        )
     )
  )
);

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-08-22 01:23:20 +02:00
parent 4717de9d08
commit 2f09ae56ad

View file

@ -104,10 +104,21 @@ CARD;
else
$card .= '<option value="' . $listValues['value'] . '">' . $listValues['name'] . '</option>';
}else{
if(is_array($value)){
$card.='<optgroup label="'.htmlentities($name).'">';
foreach($value as $subname=>$subvalue){
if($inputEntry['defaultValue'] === $subname || $inputEntry['defaultValue'] === $subvalue)
$card .= '<option value="' . $subvalue . '" selected>' . $subname . '</option>';
else
$card .= '<option value="' . $subvalue . '">' . $subname . '</option>';
}
$card.='</optgroup>';
}else{
if($inputEntry['defaultValue'] === $name || $inputEntry['defaultValue'] === $value)
$card .= '<option value="' . $value . '" selected>' . $name . '</option>';
else
$card .= '<option value="' . $value . '">' . $name . '</option>';
}
}
}