我正在使用FullCalendar,它的工作非常完美,但是当我点击重定向到查看页面时,我需要将href添加到按钮className ='btn'。
我在控制器中的代码:
public function actionIndex()
{
$events = event::find()->all();
$taskes=[];
foreach ($events as $eve)
{
$event1 = new \yii2fullcalendar\models\Event();
$patient = patient::findOne($eve->patient_id);
$event1->className='btn'; // this button that i need to add link to : ['site/view', 'id' => $id ]
$event1->id = $eve->id;
$event1->title = $patient->patient_name;
$event1->start = $eve->event_date;
$taskes[] = $event1;
}
return $this->render('index', [
'events'=>$taskes,
]);
}
答案 0 :(得分:0)
我认为你可以这样做:
...
$event1->url = Url::to(['site/view', 'id' => $id ]);
...