1. Go to this page and download the library: Download inquid/yii2-calendar library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
inquid / yii2-calendar example snippets
class Calendar extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'calendar';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['date', 'val'], '
class CalendarController extends Controller
{
public function actionIndex()
{
$searchModel = new CalendarSearch;
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams());
return $this->render('index', [
'dataProvider' => $dataProvider
]);
}
}
use marekpetras\calendarview\CalendarView;
echo CalendarView::widget(
[
// mandatory
'dataProvider' => $dataProvider,
'dateField' => 'date',
'valueField' => 'val',
// optional params with their defaults
'unixTimestamp' => false, // indicate whether you use unix timestamp instead of a date/datetime format in the data provider
'weekStart' => 1, // date('w') // which day to display first in the calendar
'title' => 'Calendar',
'views' => [
'calendar' => '@vendor/marekpetras/yii2-calendarview-widget/views/calendar',
'month' => '@vendor/inquid/yii2-calendar/views/month',
'day' => '@vendor/inquid/yii2-calendar/views/day',
],
'startYear' => date('Y') - 1,
'endYear' => date('Y') + 1,
'link' => false,
/* alternates to link , is called on every models valueField, used in Html::a( valueField , link )
'link' => 'site/view',
'link' => function($model,$calendar){
return ['calendar/view','id'=>$model->id];
},
*/
'dayRender' => false,
/* alternate to dayRender
'dayRender' => function($model,$calendar) {
return '<p>'.$model->id.'</p>';
},
*/
]
);
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.