Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yii2: How to work with font awesome icons?

I have this HTML link tag that I need to generate using yii\helpers\Html

<a href="register" class="btn btn-black" title="Sign Up"><i class="fa fa-fw fa-user"></i> Sign Up</a>

I am able to do it using method a() but I do not know how to include the font awesome class. Here is the code that I already have using a() method

<?= Html::a('Sign Up',['site/signup'], ['class' => 'btn btn-black', 'title' => 'Sign Up']) ?>

I am using bootstrap for my CSS. Any help would be appreciated.

like image 441
Zack Avatar asked Apr 15 '15 08:04

Zack


2 Answers

Following code generate your desired HTML.

<?= Html::a(Html::tag('i', '', ['class' => 'fa fa-fw fa-user']) . ' Sign Up ', ['site/signup'], ['class' => 'btn btn-black', 'title' => 'Sign Up']) ?>
like image 128
Jayson Avatar answered Oct 15 '22 07:10

Jayson


It's simple

<?= Html::a('<i class="fa fa-fw fa-user"></i> Sign Up',['site/signup'], ['class' => 'btn btn-black', 'title' => 'Sign Up']) ?>
like image 20
Alex Avatar answered Oct 15 '22 08:10

Alex