Harpreet Singh
Harpreet Singh

Reputation: 189

Yii generating wrong link

I want to add a link to a PDF file but instead of printing the link, Yii simply prints my link code

$this->widget('zii.widgets.CDetailView', array(
    'data'=>$model,
    'attributes'=>array(
        'usrname',
        array(
            'name'=>'module_id',
            'value'=>$model->ModelName('module_id')
        ),
        'filename',
        'desc',
        array(
            'name'=>'state_id',
            'value'=>$model->StateName('state_id')
        ),
        'dtop',
        array(
            'label'=>'path',
            'value'=> CHtml::link(CHtml::encode($model->path), 'c:/xampp/htdocs'.Yii::app()->baseUrl . '/upload/' . $model->path)
        )
    ),
));

and output is something like

User name        :harpreet
Module           :CSD Admin
File name        :cvcxv
Description      :sdsdfs
State            :Creation
Date of publish  :2012-03-28 13:48:43
path             :<a href="c:/xampp/htdocs/changelog_yii/upload/1index.php.txt">1index.php.txt</a>

Upvotes: 0

Views: 793

Answers (1)

bool.dev
bool.dev

Reputation: 17478

Use the type property of CDataColumn, and your type will be raw.

array(
   'label'=>'path',
   'value'=> CHtml::link(CHtml::encode($model->path), 'c:/xampp/htdocs'.Yii::app()->baseUrl . '/upload/' . $model->path),
   'type'=>'raw'
)

Upvotes: 1

Related Questions