CHtml htmlOptions in CGridView

Guys, kind of new of this forum. Have been developing in Yii for a couple of months, havent had much trouble.

Anyways I encountered this bug: when I use CGridView and use an expression to generate an image tag (for deleting a row) the Image or Link will not ‘listen’ to the htmlOptions array given: for example:

'value' => 'CHtml::link(CHtml::image(url("/images/remove.png"), "Verwijder bericht",array("rel" => $data->id)), "#")',

This will result in an a,image tag:

<a href="#"><img src="/images/remove.png" alt="Verwijder bericht"></a>

But ofcourse the image tag should contain a ‘rel’ attribute, it does not.

If I execute this code outside CGridview it functions within normal paramters.

Any idea’s?

Just tested your code and it works on my side. The “rel” attribute appears with the id’s value set properly; and of course your code looks alright. Displaying an image you need to set type=raw but if you don’t the HTML code will be displayed as text with the “rel” attribute. If your model was lacking the id you would see another error message. Having said all this I don’t have any clue why you can’t get the “rel” attribute.

Just in case… what Yii version are you using?

And please post the entire array element where you display the image. Here’s mine:






	'value'=>'CHtml::link(CHtml::image(url("/images/icons/square_".($data->active?\'green\':\'red\').".png"), "Status", array("rel"=>$data->id, "style"=>"background-color:black;")), "#")',


	'htmlOptions'=>array('style'=>'padding-left:5px; padding-right:5px; text-align:center;'),


Added another element (style) to the array - works fine as well!

[color="#006400"]/* moved from bug discussions to Yii 1.1 general help forum */[/color]