yii2: How to work with font awesome icons?

Zack picture Zack · Apr 15, 2015 · Viewed 15k times · Source

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.

Answer

Alex picture Alex · Apr 15, 2015

It's simple

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