In my view I have a link which is calling a function in Controller. The function in controller is making a pdf. It is supposed to make pdf of only $model->id
. But I am unable to send the value of $model->id into controller via my link.
View
<?php
echo CHtml::link('Save/Print',array('print'),array('class'=>'btnPrint btn btn-info','target'=>'new'));
?>
<?php
$this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'id',
'name',
'father_name',
'cnic',
'customername',
),
));
?>
Controller
public function actionPrint($id) {
ini_set('max_execution_time',360);
ini_set('memory_limit', '128M');
$mPDF1 = Yii::app()->ePdf->mpdf('','A4');
$mPDF1->SetHTMLHeader('<h3 style="text-align: center;">'.mb_strtoupper(str_replace('Hello','',Yii::app()->name),'UTF-8').'</h3>');
// $id=35;
$records = Candidate::model()->findByPk($id);
$html = '';
$html .= $this->renderPartial('view', array('model'=>$records),true);
$mPDF1->WriteHTML($html, false);
$mPDF1->Output();
}
How will I send the value of id?
go like this for singel link
// $model->id is the id you want to send
echo CHtml::link(
'Save/Print',
Yii::app()->createUrl('Save/Print' , array('id' => $model->id)),
array('class'=>'btnPrint btn btn-info','target'=>'_blank'));
if you want it in a grid
$this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
array(
'name' => 'id',
'value' => 'echo CHtml::link(
"Save/Print",
Yii::app()->createUrl("Save/Print" , array("id" => $data->id)),
array("class"=>"btnPrint btn btn-info","target"=>"_blank"));',
'type' => 'raw',
),
'name',
'father_name',
'cnic',
'customername',
),
));