Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\bootstrap;
  8. use yii\helpers\Html;
  9. /**
  10. * Button renders a bootstrap button.
  11. *
  12. * For example,
  13. *
  14. * ```php
  15. * echo Button::widget([
  16. * 'label' => 'Action',
  17. * 'options' => ['class' => 'btn-lg'],
  18. * ]);
  19. * ```
  20. * @see http://getbootstrap.com/javascript/#buttons
  21. * @author Antonio Ramirez <amigo.cobos@gmail.com>
  22. * @since 2.0
  23. */
  24. class Button extends Widget
  25. {
  26. /**
  27. * @var string the tag to use to render the button
  28. */
  29. public $tagName = 'button';
  30. /**
  31. * @var string the button label
  32. */
  33. public $label = 'Button';
  34. /**
  35. * @var boolean whether the label should be HTML-encoded.
  36. */
  37. public $encodeLabel = true;
  38. /**
  39. * Initializes the widget.
  40. * If you override this method, make sure you call the parent implementation first.
  41. */
  42. public function init()
  43. {
  44. parent::init();
  45. $this->clientOptions = false;
  46. Html::addCssClass($this->options, 'btn');
  47. }
  48. /**
  49. * Renders the widget.
  50. */
  51. public function run()
  52. {
  53. $this->registerPlugin('button');
  54. return Html::tag($this->tagName, $this->encodeLabel ? Html::encode($this->label) : $this->label, $this->options);
  55. }
  56. }