Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

61 lines
1.3KB

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