You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.3 KiB
61 lines
1.3 KiB
12 years ago
|
<?php
|
||
|
/**
|
||
|
* @link http://www.yiiframework.com/
|
||
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||
|
* @license http://www.yiiframework.com/license/
|
||
|
*/
|
||
|
|
||
|
namespace yii\bootstrap;
|
||
|
|
||
|
/**
|
||
12 years ago
|
* Button renders a bootstrap button.
|
||
12 years ago
|
*
|
||
|
* For example,
|
||
|
*
|
||
|
* ```php
|
||
11 years ago
|
* echo Button::widget([
|
||
12 years ago
|
* 'label' => 'Action',
|
||
11 years ago
|
* 'options' => ['class' => 'btn-lg'],
|
||
|
* ]);
|
||
12 years ago
|
* ```
|
||
11 years ago
|
* @see http://getbootstrap.com/javascript/#buttons
|
||
12 years ago
|
* @author Antonio Ramirez <amigo.cobos@gmail.com>
|
||
|
* @since 2.0
|
||
|
*/
|
||
|
class Button extends Widget
|
||
|
{
|
||
11 years ago
|
/**
|
||
|
* @var string the tag to use to render the button
|
||
|
*/
|
||
|
public $tagName = 'button';
|
||
|
/**
|
||
|
* @var string the button label
|
||
|
*/
|
||
|
public $label = 'Button';
|
||
|
/**
|
||
7 years ago
|
* @var bool whether the label should be HTML-encoded.
|
||
11 years ago
|
*/
|
||
|
public $encodeLabel = true;
|
||
12 years ago
|
|
||
10 years ago
|
|
||
11 years ago
|
/**
|
||
|
* Initializes the widget.
|
||
|
* If you override this method, make sure you call the parent implementation first.
|
||
|
*/
|
||
|
public function init()
|
||
|
{
|
||
|
parent::init();
|
||
|
$this->clientOptions = false;
|
||
10 years ago
|
Html::addCssClass($this->options, ['widget' => 'btn']);
|
||
11 years ago
|
}
|
||
12 years ago
|
|
||
11 years ago
|
/**
|
||
|
* Renders the widget.
|
||
|
*/
|
||
|
public function run()
|
||
|
{
|
||
|
$this->registerPlugin('button');
|
||
10 years ago
|
return Html::tag($this->tagName, $this->encodeLabel ? Html::encode($this->label) : $this->label, $this->options);
|
||
11 years ago
|
}
|
||
12 years ago
|
}
|