Yii Framework Forum: I Can't Render Html Properly - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

I Can't Render Html Properly I can't render html properly Rate Topic: -----

#1 User is offline   ferminako 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 67
  • Joined: 27-February 13

Posted 05 March 2013 - 12:12 PM

Hi everyone, I'm trying to render some contents of my database, and them contains html tags, the problem is that when I render the page, I see the html tags instead of a right render.

Things like <b>...</b>

I looked for it, and found "solutions" like :

echo CHtml::decode($model->attribute); 


But it doesn't work for my.... any suggestions?


Thanks!
0

#2 User is offline   outrage 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 313
  • Joined: 10-November 09
  • Location:Blackpool, United Kingdom

Posted 05 March 2013 - 01:25 PM

Was your html saved in the db after being encoded with CHtml::encode() within Yii, or was it already encoded?

If it was encoded outside of Yii or using some other method, you may need to use htmlspecialchars_decode

Look at the flags that can be set.
0

#3 User is offline   ferminako 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 67
  • Joined: 27-February 13

Posted 05 March 2013 - 03:54 PM

finally it works but I have another problem because I need to decode this also in widgets that I use like
'zii.widgets.CDetailView' or 'zii.widgets.grid.CGridView' I use these in the detailview and gridview but there I don't have any similar to :

echo CHtml::


I was looking for any clues and I found that there is an option like "type"=>"html", y tried it in the field that I want to render properly html code but it didn't work:


<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'experiencia-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'field0',
'field1',
'field2'=>array(
"type"=>"html",
),
array(
'class'=>'CButtonColumn',
),
),
)); ?>

Does anyone know any about this?

Thanks again!

Edit:
I've just found the solution
array('name'=>"attribute","type"=>"raw")

Thanks!

This post has been edited by ferminako: 05 March 2013 - 04:10 PM

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users