function public function Element::setIcon

8.x-3.x Element.php public Element::setIcon(array $icon = NULL)

Adds an icon to button element based on its text value.

Parameters

array $icon: An icon render array.

Return value

static

Class

Element
Provides helper methods for Drupal render elements.

Namespace

Drupal\bootstrap\Utility

Source src/Utility/Element.php (line 713)

public function setIcon(array $icon = NULL) {
  if ($this->isButton() && !Bootstrap::getTheme()->getSetting('button_iconize')) {
    return $this;
  }
  if ($value = $this->getProperty('value', $this->getProperty('title'))) {
    $icon = isset($icon) ? $icon : Bootstrap::glyphiconFromString($value);
    $this->setProperty('icon', $icon);
  }
  return $this;
}