src/Form/Components/Combo.php
public function render()
  {
    $itemHtml = static::getAssetContent('comboitem');

    $addContent = '';
    foreach ($this->values as $v) {
      $ac = $itemHtml;
      $ac = str_replace('%name%', $this->getName().'[]', $ac);
      $ac = str_replace('%item_label%', $v['label'], $ac);
      $ac = str_replace('%item_value%', $v['value'], $ac);
      $ac = str_replace('%uid%', uniqid(), $ac);
      $selected = '';

      $val = $this->getValue();
      if (is_array($val)) {
        if (is_numeric(array_search($v['value'], $val))) {
          $selected = 'checked="checked" ';
        }
      } else {
        if ($val == $v['value']) {
          $selected = 'checked="checked" ';
        }
      }

      if (is_numeric(array_search($v['value'], $this->checkedValues))) {
        $selected = 'checked="checked" ';
      }

      $ac = str_replace('%item_selected%', $selected, $ac);
      $addContent .= $ac;
    }
    $addContent = parent::replaceMagicFields($addContent);

    $html = parent::render();
    $html = str_replace('%items%', $addContent, $html);
    return $html;
  }
public function render()
  {
    $itemHtml = static::getAssetContent('comboitem');

    $addContent = '';
    foreach ($this->values as $v) {
      $ac = $itemHtml;
      $ac = str_replace('%name%', $this->getName().'[]', $ac);
      $ac = str_replace('%item_label%', $v['label'], $ac);
      $ac = str_replace('%item_value%', $v['value'], $ac);
      $ac = str_replace('%uid%', uniqid(), $ac);
      $selected = '';

      $val = $this->getValue();
      if (is_array($val)) {
        if (is_numeric(array_search($v['value'], $val))) {
          $selected = 'checked="checked" ';
        }
      } else {
        if ($val == $v['value']) {
          $selected = 'checked="checked" ';
        }
      }

      if (is_numeric(array_search($v['value'], $this->checkedValues))) {
        $selected = 'checked="checked" ';
      }

      $ac = str_replace('%item_selected%', $selected, $ac);
      $addContent .= $ac;
    }
    $addContent = parent::replaceMagicFields($addContent);

    $html = parent::render();
    $html = str_replace('%items%', $addContent, $html);
    return $html;
  }
Rendu du composant

@return type