How add icon in DetailView Widgets

201 Views Asked by At

I want to insert an icon in front of the attributes, how can I do it. this is my code.

                    <?= DetailView::widget([
                        'model' => $model,
                        'options' => ['class'=>'table','style'=>'margin-bottom:0.2em;'],
                        'attributes' => [
                        'DT_NASC',
                          ['attribute'=>'PR_GENERO_ID','value'=>$model->pRGENERO->DESIG],
                        ['attribute'=>'PR_PROFISSAO_ID','value'=>$model->pRPROFISSAO->DESIG],
                        ['attribute'=>'LOCALIDADE_ID','value'=>$model->lOCALIDADE->NOME],
                        ['attribute'=>'NACIONALIDADE_ID','value'=>$model->nACIONALIDADE-> NACIONALIDADE],
                        'OBS:ntext',
                     //'DT_REGISTO',
                    ],
                ]) ?>
1

There are 1 best solutions below

0
Kandarp Patel On

Add another parameter "format" and its value "html" in the attribute definition. And than you can append the icon as html with value

['attribute'=>'PR_GENERO_ID','value'=>'icon goes here '.$model->pRGENERO->DESIG,'format'=>'html']

Example:

['attribute'=>'PR_GENERO_ID','value'=>'<i class="glyphicon glyphicon-remove"></i> '.$model->pRGENERO->DESIG,'format'=>'html']

Or if you want icon with in attribute label add parameter "label" and append icon with the label name

['label'=>'<i class="glyphicon glyphicon-remove"></i> PR_GENERO_ID','attribute'=>'PR_GENERO_ID','value'=>'<i class="glyphicon glyphicon-remove"></i> '.$model->pRGENERO->DESIG,'format'=>'html']