Pregunta

I have big problems in generating a button in CGridView that opens a page in a new browser window. This is the code, I use:

'preview' => array(
  'value' => 'CHtml::link("test", array("classified/preview", "id"=>$data->id), array("target"=>"_blank"))',
  'header' => 'Name',
  'name' => 'name',
  'type' => 'raw',
),

The generated link looks like this:

http://localhost/fotomarkt/index.php?r=classified/listmine#

So the link is wrong and the "target=_blank" is ignored.

I also saw this with bool.dev's good answer, but somehow, it doesn't work for me...

I guess, it's something stupid, which I simply don't see...

¿Fue útil?

Solución

The code above is fine for a CGridColumn. However, it looks like you are using a CButtonColumn. The code below should suffice.

'preview' => array(
    'url' => 'array("classified/preview", "id"=>$data->id)',
    'label'=>'test',
    'options'=>array("target"=>"_blank"),
),

Also if you require a column in which each cell contains a single link only, a CLinkColumn would be more suited than a CGridColumn.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top