Button

Drafting Buttons by the Yii way

//simple text button
echo CHtml::button('Button Text', 
          array('submit' => array('controller/action')));

This will render the following code

<input id="yt0" type="button" value="Button Text" name="yt0"/>
<script type="text/javascript">
/*<![CDATA[*/
jQuery(document).ready(function() {
             jQuery('#yt0').click(function( {
                            jQuery.yii.submitForm(
                                     this,
                                     'controller/action',{}
                                          );return false;});
                                  });
/*]]>*/
</script>

your code here
your code here
your code here
//Button with confirmation
CHtml::button('Delete', 
     array('submit' => array('user/delete','id'=>$model->usId),
          'name'=>'btnDelete',
          'confirm'=>'Are you sure you want to delete?',
          'class'=>'btn btn-large btn-danger',
          'style'=>'width:160px;'
     ));




Advertisements
Posted in CHtml

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Recent Posts
Recent Comments
Archives
Categories
%d bloggers like this: