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.
63 lines
1.2 KiB
63 lines
1.2 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
|
use yii\helpers\Html;
|
||
12 years ago
|
|
||
|
/**
|
||
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
|
* ```
|
||
|
* @see http://twitter.github.io/bootstrap/javascript.html#buttons
|
||
|
* @author Antonio Ramirez <amigo.cobos@gmail.com>
|
||
|
* @since 2.0
|
||
|
*/
|
||
|
class Button extends Widget
|
||
|
{
|
||
12 years ago
|
/**
|
||
|
* @var string the tag to use to render the button
|
||
|
*/
|
||
|
public $tagName = 'button';
|
||
|
/**
|
||
|
* @var string the button label
|
||
|
*/
|
||
|
public $label = 'Button';
|
||
|
/**
|
||
|
* @var boolean whether the label should be HTML-encoded.
|
||
|
*/
|
||
|
public $encodeLabel = true;
|
||
12 years ago
|
|
||
|
|
||
12 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;
|
||
12 years ago
|
Html::addCssClass($this->options, 'btn');
|
||
12 years ago
|
}
|
||
12 years ago
|
|
||
12 years ago
|
/**
|
||
|
* Renders the widget.
|
||
|
*/
|
||
|
public function run()
|
||
|
{
|
||
|
echo Html::tag($this->tagName, $this->encodeLabel ? Html::encode($this->label) : $this->label, $this->options);
|
||
|
$this->registerPlugin('button');
|
||
|
}
|
||
|
}
|