<?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 switch ($this->typeChampDestinataires) {
    case 'select': ?>
    <select name="<?=$this->name?>" id="ctrl_<?=$this->id?>" <?=$this->getAttributes()?>>
        <option value=""><?=($this->placeholder == '') ? "choisissez une option" : $this->placeholder;?></option>
        <?php foreach ($this->arrOptions as $item): ?>
            <option value="<?=$item['value']?>"><?=$item['label']?></option>
        <?php endforeach;?>
    </select>
    <?php break;
    case 'radio': ?>
        <fieldset id="ctrl_<?=$this->id?>" class="radio_container">
            <?php foreach ($this->arrOptions as $item): ?>
                <div>
                    <input type="radio" name="<?=$this->name?>" id="ctrl_<?=$this->id?>_<?=$item['value']?>" value="<?=$item['value']?>">
                    <label for="ctrl_<?=$this->id?>_<?=$item['value']?>"><?=$item['label']?></label>
                </div>
            <?php endforeach;?>
        </fieldset>
    <?php break;
    case 'checkbox': ?>
        <fieldset id="ctrl_<?=$this->id?>" class="checkbox_container">
            <?php foreach ($this->arrOptions as $item): ?>
                <div>
                    <input type="checkbox" name="<?=$this->name?>[]" id="ctrl_<?=$this->id?>_<?=$item['value']?>" value="<?=$item['value']?>">
                    <label for="ctrl_<?=$this->id?>_<?=$item['value']?>"><?=$item['label']?></label>
                </div>
            <?php endforeach;?>
        </fieldset>
    <?php break;
}?>
<?php $this->endblock();?>
