L
L
Lander2015-08-14 15:55:09
Yii
Lander, 2015-08-14 15:55:09

How to make FullCalendar and Yii2 friends?

Has anyone used https://github.com/thiagotalma/yii2-talma-fullcale...
Made it fire events but can't seem to get it to react to clicks to fire events. I do it like this:

<?php

use \talma\widgets\FullCalendar;

?>

<?= FullCalendar::widget([
    'loading' => 'Загрузка...', 
  'config' => [
    'header' => [
      'left' => 'prev,next today',
      'center' => 'title',
      'right' => 'month,basicWeek,basicDay'
    ],
    'editable' => true,
    'lang' => 'ru',
    'events' => $events,
    'dayClick' => '...' //Вот тут начинаются проблемы
    
  ]
]); ?>

In general, I do not understand what, where and how to write. Consider docks on a component that is not present. In the source code of the component itself, nothing came to mind.
Thanks in advance for your help and ideas.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Grechushnikov, 2015-08-14
@maxyc_webber

"philippfrenzel/yii2fullcalendar": "dev-master",

<?= yii2fullcalendar\yii2fullcalendar::widget([
            'id'=>'calendar',ru
            'clientOptions' => [
                'language' => 'ru',
                'eventLimit'=> true,
                'fixedWeekCount'=>false,
                'eventLimitClick'=>new \yii\web\JsExpression('function (cellInfo, jsEvent) {showEvents(cellInfo.date, cellInfo.segs);}')
            ],
            'header' => [
                'center'=>'',
                'left'=>'title',
                'right'=>'prev,next today'
            ],
            'ajaxEvents' => Url::to(['/events/json', 'type'=>'all'])
        ]);

public function actionJson($start=NULL,$end=NULL,$_=NULL)
    {
        \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

        $times = Event::find()->where(['between', 'date', $start,$end])->all();

        $events = array();

        foreach ($times AS $time) {

            $Event = new \yii2fullcalendar\models\Event();
            $Event->id = $time->id;
            $Event->title = $time->name;
            $Event->allDay = true;

            if($time->club_id) { // если от клубов, то класс один, иначе другой
                $Event->className = 'event-club';
            } else {
                $Event->className = 'event-default';
            }

            $Event->start = date('Y-m-d',strtotime($time->date));
            $Event->url = \yii\helpers\Url::to(['/events/view', 'id'=>$time->id]);
            $events[] = $Event;

        }

        return $events;
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question