src/Form/Components/SelectMultiple.php
public function render()
  {
    $optionHtml = static::getAssetContent('option');

    $addContent = '';
    foreach ($this->values as $k => $option) {
      $ac = $optionHtml;
      $attributes = '';
      if (count($option['attributes']) > 0) {
        foreach ($option['attributes'] as $att_k => $att_v) {
          $attributes .= ' '.$att_k.'="'.$att_v.'"';
        }
      }
      $ac = str_replace('%value%', $option['value'], $ac);
      $ac = str_replace('%attributes%', $attributes, $ac);
      $ac = str_replace('%label%', $k, $ac);

      $selected = false;
      if (array_search($option['value'], $this->selectedValues) !== false) {
        $selected = true;
      }

      if ($selected) {
        $ac = str_replace('%selected%', 'selected="selected"', $ac);
      } else {
        $ac = str_replace('%selected%', '', $ac);
      }

      $addContent .= $ac;
    }

    $html = parent::render();
    $strAttributes = '';
    foreach ($this->selectattributes as $key => $value) {
      $strAttributes .= ' ' . $key . '="' . $value . '"';
    }
    $html = str_replace('%selectattributes%', $strAttributes, $html);
    $html = str_replace('%items%', $addContent, $html);

    return $html;
  }
public function render()
  {
    $optionHtml = static::getAssetContent('option');

    $addContent = '';
    foreach ($this->values as $k => $option) {
      $ac = $optionHtml;
      $attributes = '';
      if (count($option['attributes']) > 0) {
        foreach ($option['attributes'] as $att_k => $att_v) {
          $attributes .= ' '.$att_k.'="'.$att_v.'"';
        }
      }
      $ac = str_replace('%value%', $option['value'], $ac);
      $ac = str_replace('%attributes%', $attributes, $ac);
      $ac = str_replace('%label%', $k, $ac);

      $selected = false;
      if (array_search($option['value'], $this->selectedValues) !== false) {
        $selected = true;
      }

      if ($selected) {
        $ac = str_replace('%selected%', 'selected="selected"', $ac);
      } else {
        $ac = str_replace('%selected%', '', $ac);
      }

      $addContent .= $ac;
    }

    $html = parent::render();
    $strAttributes = '';
    foreach ($this->selectattributes as $key => $value) {
      $strAttributes .= ' ' . $key . '="' . $value . '"';
    }
    $html = str_replace('%selectattributes%', $strAttributes, $html);
    $html = str_replace('%items%', $addContent, $html);

    return $html;
  }
Rendu du composant
@return string