Question

Here is nice collection of icons caleld Glyphicons http://getbootstrap.com/components/ They act like nice buttons, just without hyperlinks. Just mouseover actions.

What I want is to make buttons with hyperlinks and such style. I have Bootstrap installed so I can use that css class. Problem is that structure of button there is

<ul class='bs-glyphicon-list'><li><span>...</span><span>...</span></li></ul>

and if I use yii CHtml button then I have to write something like:

CHtml::link(BsHtml::icon(BsHtml::GLYPHICON_PLUS).'some text', 
array('controller/action'), $htmlOptions=array ('class'=>'bs-glyphicon-list'));

Problem is that that additional html options will be passed to tag itself. And I have to make ul+li+span junction. How can I achive this ?

Was it helpful?

Solution

I was a little unclear on what the problem here is. But this should work if you use Chtml::htmlbutton.

<?php echo CHtml::htmlButton('<i class="glyphicon glyphicon-plus"></i> ' . Yii::t('search', 'Search'), array('class'=>'btn btn-primary', 'id'=>'submit-search', 'type'=>'submit')); ?>

but htmlButton allows you to use the glyiphicons in plain text, whilst still passing other css and options to it.

Will render a bootstrap button with chosen glyphicon in the text

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top