2017 © Pedro Peláez
 

yii2-extension yii2-datepicker

Bootstrap 3 Date/time picker widget for Yii2

image

nex/yii2-datepicker

Bootstrap 3 Date/time picker widget for Yii2

  • Tuesday, January 30, 2018
  • by RomeroMsk
  • Repository
  • 2 Watchers
  • 10 Stars
  • 12,131 Installations
  • PHP
  • 10 Dependents
  • 0 Suggesters
  • 10 Forks
  • 1 Open issues
  • 1 Versions
  • 10 % Grown

The README.md

Bootstrap 3 date/time picker widget for Yii2

Credits

Jonathan Peterson (@Eonasdan) for Bootstrap 3 Date/Time Picker., (*1)

Antonio Ramirez (@tonydspaniard) for inspiration by Bootstrap DatePicker Widget for Yii2 and code examples., (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require "nex/yii2-datepicker" "*"

or add, (*5)

"nex/yii2-datepicker": "*"

to the require section of your application's composer.json file., (*6)

Usage

Please refer to the Datepicker documentation web page for options and examples of using Eonasdan's Datepicker widget., (*7)

To use widget as date/time picker, set appropriate format, e.g. 'L LT' (as in examples below). See momentjs' docs for valid formats., (*8)

With a model, (*9)



= DatePicker::widget([
    'model' => $model,
    'attribute' => 'attrName',
    'language' => 'ru',
    'size' => 'lg',
    'readonly' => true,
    'placeholder' => 'Choose date',
    'clientOptions' => [
        'format' => 'L',
        'minDate' => '2015-08-10',
        'maxDate' => '2015-09-10',
    ],
    'clientEvents' => [
        'dp.show' => new \yii\web\JsExpression("function () { console.log('It works!'); }"),
    ],
]);?>

= $form->field($model, 'attrName')->widget(
    DatePicker::className(), [
        'addon' => false,
        'size' => 'sm',
        'clientOptions' => [
            'format' => 'L LT',
            'stepping' => 30,
        ],
]);?>

Without a model, (*10)

<?php
use nex\datepicker\DatePicker;
?>
<?= DatePicker::widget([
    'name' => 'datepickerTest',
    'value' => '09/13/2015',
    'clientOptions' => [
        'format' => 'L',
    ],
    'dropdownItems' => [
        ['label' => 'Yesterday', 'url' => '#', 'value' => \Yii::$app->formatter->asDate('-1 day')],
        ['label' => 'Tomorrow', 'url' => '#', 'value' => \Yii::$app->formatter->asDate('+1 day')],
        ['label' => 'Some value', 'url' => '#', 'value' => 'Special value'],
    ],
]);?>

The Versions

30/01 2018

dev-master

9999999-dev https://github.com/RomeroMsk/yii2-datepicker

Bootstrap 3 Date/time picker widget for Yii2

  Sources   Download

BSD-3-Clause BSD 3-Clause

The Requires

 

extension yii2 bootstrap widget datepicker datetimepicker