<?php $this->extend('form_row'); ?> <?php $this->block('label'); ?> <?php if ($this->label): ?> <label for="ctrl_<?= $this->id ?>"<?php if ($this->class): ?> class="<?= $this->class ?>"<?php endif; ?>> <?php if ($this->mandatory): ?> <span class="invisible"><?= $this->mandatoryField ?> </span><?= $this->label ?><span class="mandatory">*</span> <?php else: ?> <?= $this->label ?> <?php endif; ?> </label> <?php endif; ?> <?php $this->endblock(); ?> <?php $this->block('field'); ?> <?php if ($this->multiple): ?> <input type="hidden" name="<?= rtrim($this->name, '[]') ?>" value=""> <?php endif; ?> <select name="<?= $this->name ?>" id="ctrl_<?= $this->id ?>" class="<?= $this->class ?>"<?= $this->getAttributes() ?>> <?php foreach ($this->getOptions() as $option): ?> <?php if ('group_start' == $option['type']): ?> <optgroup label="<?= $option['label'] ?>"> <?php endif; ?> <?php if ('option' == $option['type']): ?> <option value="<?= $option['value'] ?>"<?= $option['selected'] ?>><?= $option['label'] ?></option> <?php endif; ?> <?php if ('group_end' == $option['type']): ?> </optgroup> <?php endif; ?> <?php endforeach; ?> </select> <?php if ($this->hasErrors()): ?> <p class="error"><?= $this->getErrorAsString() ?></p> <?php endif; ?> <?php $this->endblock(); ?>