Yii2 FullCalendar:如何添加链接按钮

时间:2016-08-28 07:09:16

标签: php html yii2 fullcalendar yii2-advanced-app

我正在使用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,
    ]);
}

the button i need add link

1 个答案:

答案 0 :(得分:0)

我认为你可以这样做:

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

查看文档 - http://fullcalendar.io/docs/event_data/Event_Object/