mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 14:46:19 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			63 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/**
 | 
						|
 * @link http://www.yiiframework.com/
 | 
						|
 * @copyright Copyright (c) 2008 Yii Software LLC
 | 
						|
 * @license http://www.yiiframework.com/license/
 | 
						|
 */
 | 
						|
 | 
						|
namespace yii\bootstrap;
 | 
						|
 | 
						|
use yii\helpers\Html;
 | 
						|
 | 
						|
/**
 | 
						|
 * Button renders a bootstrap button.
 | 
						|
 *
 | 
						|
 * For example,
 | 
						|
 *
 | 
						|
 * ```php
 | 
						|
 * echo Button::widget([
 | 
						|
 *     'label' => 'Action',
 | 
						|
 *     'options' => ['class' => 'btn-lg'],
 | 
						|
 * ]);
 | 
						|
 * ```
 | 
						|
 * @see http://twitter.github.io/bootstrap/javascript.html#buttons
 | 
						|
 * @author Antonio Ramirez <amigo.cobos@gmail.com>
 | 
						|
 * @since 2.0
 | 
						|
 */
 | 
						|
class Button extends Widget
 | 
						|
{
 | 
						|
	/**
 | 
						|
	 * @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;
 | 
						|
 | 
						|
 | 
						|
	/**
 | 
						|
	 * Initializes the widget.
 | 
						|
	 * If you override this method, make sure you call the parent implementation first.
 | 
						|
	 */
 | 
						|
	public function init()
 | 
						|
	{
 | 
						|
		parent::init();
 | 
						|
		$this->clientOptions = false;
 | 
						|
		Html::addCssClass($this->options, 'btn');
 | 
						|
	}
 | 
						|
 | 
						|
	/**
 | 
						|
	 * Renders the widget.
 | 
						|
	 */
 | 
						|
	public function run()
 | 
						|
	{
 | 
						|
		echo Html::tag($this->tagName, $this->encodeLabel ? Html::encode($this->label) : $this->label, $this->options);
 | 
						|
		$this->registerPlugin('button');
 | 
						|
	}
 | 
						|
}
 |