i have a view page using CDetailView,
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'id',
'name',
array(
'label'=>'Keyword',
'type'=>'html',
'value'=>getKeywordsHtml($model),
),
)); ?>
the function getKeywordsHtml() is defined in same file as below.
<?php
function getKeywordsHtml($model)
{
$keywordsHtml='';
foreach ($model->keywords as $keyword)
{
$keywordsHtml = $keywordsHtml.
CHtml::link($keyword->name,array('keyword/view', 'id'=>$keyword->id)).
CHtml::link(' [del] ',
array('problem/delkeyword', 'id'=>$model->id, 'kid'=>$keyword->id),
array(
'submit'=>array(
'/problem/delkeyword',
'id'=>$model->id,
'kid'=>$keyword->id
),
'class' => 'delete',
'confirm'=>'Are you sure?'
)
).'<br>';
}
return $keywordsHtml;
}
?>
I want the page to show the keyword with a del link beside it.
now the link works fine. it goes to the /delkeyword&id=1, but the confirm window didn’t work. so it the post doesn’t work.
I tried the following code outside the detail widget, it works fine.
<?php
echo CHtml::link('keyword 1',array('keyword/view','id'=>1)).CHtml::link(' [del] ',array('problem/delkeyword','id'=>1, 'kid'=>1), array('submit'=>array('/problem/delkeyword', 'id'=>1, 'kid'=>1),'class' => 'delete','confirm'=>'Are you sure?')).'<br>';
?>
And the html output
work outside CDetailview:
<a class="delete" href="#" id="yt3"> [del] </a>
not work in CDetailview:
<a class="delete" href="#" > [del] </a>
So how should i modify my code?