Tutorial Yii2 Bagian 33 : Full Calendar (1)
Aplikasi ini menggunakan Event Calendar. 1. Buat tabel event 2. Buat CRUD untuk tabel event 3. Install philippfrenzel yii-calendar melalui composer: https://github.com/philippfrenzel/yii2fullcalendar 4. Modifikasi frontend/controllers/EventController.php pada actionIndex
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
public function actionIndex() { $events = \common\models\Event::find()->all(); $tasks = []; foreach ($events as $eve) { $event = new \yii2fullcalendar\models\Event(); $event->id = $eve->id; $event->title = $eve->title; $event->start = $eve->created_date; $tasks[] = $event; } return $this->render('index', [ 'events' => $tasks, ]); } |
5. Modifikasi frontend/views/event/index.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?php use yii\helpers\Html; use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $searchModel common\models\EventSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = Yii::t('app', 'Events'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="event-index"> <h1><?= Html::encode($this->title) ?></h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?= Html::a(Yii::t('app', 'Create Event'), ['create'], ['class' => 'btn btn-success']) ?> </p> <?= \yii2fullcalendar\yii2fullcalendar::widget(array( 'events'=> $events, ));?> </div> |
6. Event akan muncul di dalam Calendar Tutorial ini sebagai dokumentasi dan pembelajaran pribadi sekalian belajar terjemahin bahasa Inggris, dan siapa tahu bermanfaat buat Read more about Tutorial Yii2 Bagian 33 : Full Calendar (1)[…]