VinoCoder
VinoCoder

Reputation: 1153

Show fa icon inside Chtml::link() in Yii1

Im using CHtml::link() for attachment in my grid view and if i click on it, it will open in new tab to display.

My doubt is how can i use font awesome icon to display attachment in grid. Currently it showing from table but i want to display <i class="fa fa-paperclip" aria-hidden="true"></i> this icon for that column.

array(
    'name'  => 'invoice_attachment',
    'value' => 'CHtml::link($data->invoice_attachment, Yii::app()->request->baseUrl.$data->invoice_attachment, array("target"=>"_blank"))',
    'type'  => 'raw',

  ),

The above code is my current output for link.

Upvotes: 1

Views: 493

Answers (1)

Yupik
Yupik

Reputation: 5032

CHtml::link($text, $url, $htmlOptions) method accepts 3 parameters:

  1. $text - this is what you want, right now youre setting here $data->invoice_attachment (propably file name) - change this to your <i> string
  2. $url - a URL or an action route that can be used to create a URL
  3. $htmlOptions - additional HTML attributes

Change $text param and that's all.

Upvotes: 3

Related Questions