Naeem Marzu Naeem Marzu - 3 months ago 36
HTML Question

Yii2 FullCalendar: how to add link button

I am using FullCalendar , its work perfectly , but i need to add href to the button className='btn' when i click on redirect to view page .

my code in controller :

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,
]);
}


the button i need add link

Answer

I think you can make like this:

...
$event1->url = Url::to(['site/view', 'id' => $id ]);
...

Look in the documentation - http://fullcalendar.io/docs/event_data/Event_Object/

Comments