CJuiButton 封裝 jQuery UI Button,支援三種 buttonType 模式,提供一致視覺風格與圖示支援。
<?php $this->widget('zii.widgets.jui.CJuiButton', array(
'buttonType' => 'submit',
'name' => 'btnSubmit',
'value' => '1',
'caption' => '送出',
'htmlOptions' => array('class' => 'ui-button-primary'),
)); ?>
<?php $this->widget('zii.widgets.jui.CJuiButton', array(
'buttonType' => 'button',
'name' => 'btnClick',
'caption' => '點擊測試',
'onclick' => 'js:function(){alert("clicked"); this.blur(); return false;}',
// 'options' => array('icons' => 'js:{primary:"ui-icon-newwin"}'),
)); ?>
<?php $this->widget('zii.widgets.jui.CJuiButton', array(
'buttonType' => 'link',
'name' => 'btnGo',
'caption' => '前往其他頁',
'url' => array('site/other'),
// 'options' => array('icons' => 'js:{secondary:"ui-icon-extlink"}'),
)); ?>
options 透傳 jQuery UI Button 選項:
icons.primary:主圖示(按鈕左側)icons.secondary:次圖示(按鈕右側)text:true/false 顯示/隱藏文字ui-icon-*(如 ui-icon-search, ui-icon-plus, ui-icon-trash)scriptMap 設定<?php $form=$this->beginWidget('CActiveForm'); ?>
<?php echo $form->errorSummary($model); ?>
<div class="row buttons">
<?php $this->widget('zii.widgets.jui.CJuiButton', array(
'buttonType' => 'submit',
'caption' => $model->isNewRecord ? '建立' : '更新',
'htmlOptions' => array('class' => 'btn-primary'),
)); ?>
</div>
<?php $this->endWidget(); ?>
buttonType='submit' 必須在 <form> 內才會觸發提交onclick 回傳 false 防止預設行為(如 link 類型)disabled 屬性動態切換,需用 button('disable') 方法