<?php /** @var $this \Ardaenye\View\ViewRenderer */ ?>
<?php /** @var $element \Ardaenye\Form\Element\Select */ ?>

<select name='<?= $element->getName() ?>' <?= $element->stringifyAttributes() ?>>
    <?php if ($element->hasEmptyValue()): ?>
        <option><?= $element->getEmptyValue() ?></option>
    <?php endif ?>
    <?php foreach ($element->getValueOptions() as $option): ?>
        <?php if ($option instanceof \Ardaenye\Form\Option\OptGroup): ?>
            <?php foreach ($option->getOptions() as $opt): ?>
                <option value='<?= $opt->getValue() ?>' <?= $opt->isSelected() ? 'selected' : '' ?>><?= $opt->getName() ?></option>
            <?php endforeach ?>
        <?php else: ?>
            <option value='<?= $option->getValue() ?>' <?= $option->isSelected() ? 'selected' : '' ?>><?= $option->getName() ?></option>
        <?php endif ?>
    <?php endforeach ?>
</select>