wdmg/yii2-datepicker

Bootstrap3 DatePicker Widget for Yii2

Installs: 872

Dependents: 3

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 1

Open Issues: 0

Type:yii2-extension

1.1.0 2023-06-18 21:45 UTC

This package is auto-updated.

Last update: 2024-11-19 00:53:12 UTC


README

Progress Github all releases GitHub version Progress GitHub license

Yii2 DatePicker

Bootstrap3 DatePicker Widget for Yii2

Requirements

  • PHP 5.6 or higher
  • Yii2 v.2.0.33 and newest
  • Yii2 Bootstrap
  • Bootstrap DatePicker v.1.1.0 and newest.

Installation

To install the widget, run the following command in the console:

$ composer require "wdmg/yii2-datepicker"

Usage

Example of standalone widget:

<?php

use wdmg\widgets\DatePicker;
...

echo DatePicker::widget([
    'model' => $model,
    'attribute' => 'datetime',
    'options' => [
       'class' => 'form-control'
    ],
    'pluginOptions' => [
        'className' => '.datepicker',
        'input' => '.form-control',
        'toggle' => '.input-group-btn > button',
    ]
    ...
]);

?>

Example of use with ActiveForm:

<?php

use wdmg\widgets\DatePicker;
...

$form = ActiveForm::begin();
...
echo $form->field($model, 'datetime')->widget(DatePicker::class, [
    'options' => [
        'class' => 'form-control'
    ],
    'pluginOptions' => [
        'className' => '.datepicker',
        'input' => '.form-control',
        'toggle' => '.input-group-btn > button',
    ]
    ...
]);
...
ActiveForm::end();

?>

Options

DatePicker extends InputWidget so you can use any options available for this widget. In addition, you can use these custom options if necessary:

Status and version

  • v.1.1.0 - Update copyrights and dependencies
  • v.1.0.8 - Fixed widget ID and init after Pjax reloading