Search code examples
twitter-bootstrapbuttonyiiiconsyii-chtml

How can I integrate a simple bootstrap-button within Yii (via CHtml) without any extensions?


How could I do that with CHtml (this works within Yii too) ?

<button class="btn btn-app btn-warning">
    <i class="icon-undo bigger-230"></i>
    Undo
</button>

I've tried the following without success:

echo CHtml::link('myLabelText',array('MyController/index'), array(
    'class' =>'cMyOwnClass btn btn-app btn-warning',
    'icon'=>'icon-undo',
));

I see the button, connection to MyController is OK, CSS-classes are OK, but there is no icon.


Solution

  • You're providing the additional css info at the wrong place. Try this:

    echo CHtml::link('<i class="icon-undo"></i> myLabelText',array('MyController/index'),array(
        'class'=>'cMyOwnClass btn btn-app btn-warning',
    ));
    

    This will still generate a <a href="...">...</a>-style link, though.