Saltern Saltern - 1 year ago 411
jQuery Question

how to add a event in fullcalendar in yii2

i used this code to create a event :

<?php
use yii\helpers\Url;


$events = array();
//Testing
$Event = new \yii2fullcalendar\models\Event();
$Event->id = 1;
$Event->title = 'milad';
$Event->editable=TRUE;
$Event->start = date('Y-m-d\TH:i:s\Z');
$events[] = $Event;

$Event = new \yii2fullcalendar\models\Event();
$Event->id = 2;
$Event->title = 'Testing';
$Event->start = date('Y-m-d\TH:i:s\Z',strtotime('tomorrow 6am'));
$events[] = $Event;

?>

<?= \yii2fullcalendar\yii2fullcalendar::widget(array(
'events'=> $events,
));



?>


<?= yii2fullcalendar\yii2fullcalendar::widget([
'options' => [
'lang' => 'fa',
//... more options to be defined here!
],
'ajaxEvents' => Url::to(['/timetrack/default/jsoncalendar'])
]);
?>


how to i add a Drag-n-drop for events!
i cant find a good docs for this work !
this is e extention for fullcalender :

http://www.yiiframework.com/extension/yii2fullcalendar/

Answer

There are a lot of events for fullcalender and you can see list of these events in this link and you can use them in yii2 like this

            echo \yii2fullcalendar\yii2fullcalendar::widget([
                'id' => 'calendar',
                'clientOptions' => [
                    'language' => 'fa',
                    'eventLimit' => TRUE,
//                'theme'=>true,
                    'fixedWeekCount' => false,
                'dayClick'=>new \yii\web\JsExpression('function (cellInfo, jsEvent) {console.log(cellInfo);}')
                ],

              'ajaxEvents' => Url::to(['/timetrack/default/jsoncalendar']),                ]);