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
			| 
											13 years ago
										 | <?php
 | ||
|  | /**
 | ||
|  |  * @link http://www.yiiframework.com/
 | ||
|  |  * @copyright Copyright (c) 2008 Yii Software LLC
 | ||
|  |  * @license http://www.yiiframework.com/license/
 | ||
|  |  */
 | ||
|  | 
 | ||
|  | namespace yii\bootstrap;
 | ||
|  | 
 | ||
| 
											13 years ago
										 | use yii\helpers\Html;
 | ||
| 
											13 years ago
										 | 
 | ||
|  | /**
 | ||
| 
											13 years ago
										 |  * Button renders a bootstrap button.
 | ||
| 
											13 years ago
										 |  *
 | ||
|  |  * For example,
 | ||
|  |  *
 | ||
|  |  * ```php
 | ||
| 
											12 years ago
										 |  * echo Button::widget([
 | ||
| 
											13 years ago
										 |  *     'label' => 'Action',
 | ||
| 
											12 years ago
										 |  *     'options' => ['class' => 'btn-lg'],
 | ||
|  |  * ]);
 | ||
| 
											13 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
 | ||
|  | {
 | ||
| 
											13 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;
 | ||
| 
											13 years ago
										 | 
 | ||
|  | 
 | ||
| 
											13 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;
 | ||
| 
											13 years ago
										 | 		Html::addCssClass($this->options, 'btn');
 | ||
| 
											13 years ago
										 | 	}
 | ||
| 
											13 years ago
										 | 
 | ||
| 
											13 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');
 | ||
|  | 	}
 | ||
|  | }
 |