button() public static method

Generates a button tag.
public static button ( string $content = 'Button', array $options = [] ) : string
$content string the content enclosed within the button tag. It will NOT be HTML-encoded. Therefore you can pass in HTML code such as an image tag. If this is is coming from end users, you should consider [[encode()]] it to prevent XSS attacks.
$options array the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered.
return string the generated button tag
Beispiel #1
0
 /**
  * Creates button with FontAwesome icon.
  * @param string $text    Button text.
  * @param string $fa      Icon name.
  * @param array  $options Additional options.
  * @return string
  */
 public static function buttonFa($text, $fa, $options = [])
 {
     $icon = self::tag('i', '', ['class' => 'fa fa-' . $fa . ' margin']);
     if (isset($options['raw']) and $options['raw'] == true) {
         unset($options['raw']);
         return parent::button($icon . $text, $options);
     } else {
         unset($options['raw']);
         return parent::button($icon . Yii::t('app', $text), $options);
     }
 }