src/Peach/Markup/HtmlHelper.php
private function createOptions($current, array $candidates)
    {
        $result = new NodeList();
        foreach ($candidates as $key => $value) {
            if (is_array($value)) {
                $optgroup = new ContainerElement("optgroup");
                $optgroup->setAttribute("label", $key);
                $optgroup->appendNode($this->createOptions($current, $value));
                $result->appendNode($optgroup);
                continue;
            }
            
            $option  = new ContainerElement("option");
            $option->setAttribute("value", $value);
            $value   = Values::stringValue($value);
            if ($current === $value) {
                $option->setAttribute("selected");
            }
            $option->appendNode($key);
            $result->appendNode($option);
        }
        return $result;
    }
private function createOptions($current, array $candidates)
    {
        $result = new NodeList();
        foreach ($candidates as $key => $value) {
            if (is_array($value)) {
                $optgroup = new ContainerElement("optgroup");
                $optgroup->setAttribute("label", $key);
                $optgroup->appendNode($this->createOptions($current, $value));
                $result->appendNode($optgroup);
                continue;
            }
            
            $option  = new ContainerElement("option");
            $option->setAttribute("value", $value);
            $value   = Values::stringValue($value);
            if ($current === $value) {
                $option->setAttribute("selected");
            }
            $option->appendNode($key);
            $result->appendNode($option);
        }
        return $result;
    }
select 要素に含まれる option の一覧を作成します.

@param  string $current    デフォルト値
@param  array  $candidates 選択肢の一覧
@return NodeList option 要素の一覧