Yii 2.0: yii2-date-range

Advanced date range picker control for Yii 2.0 using Bootstrap 3.x styles
27 followers

An advanced date range picker input for Yii Framework 2 based on dangrossman/bootstrap-daterangepicker plugin. The date range picker widget is styled for Bootstrap 3.x and creates a dropdown menu from which a user can select a range of dates. If the plugin is invoked with no options, it will present two calendars to choose a start and end date from. Optionally, you can provide a list of date ranges the user can select from instead of choosing dates from the calendars. If attached to a text input, the selected dates will be inserted into the text box. Otherwise, you can provide a custom callback function to receive the selection.

Additional enhancements added for this widget (by Krajee):

  • allows ability to work with Bootstrap input group addons and set the picker position to point at the input-group-addon icon.
  • enhanced translation features providing ability to add/configure your translation for each language. In order to create your own translation, please follow these steps.
  • automatically convert format from PHP Date/time format to Moment.js Date/time format.
  • automatically trigger change of base field to enforce Yii ActiveField validation
  • ability to set the widget to display a preset dropdown of date options within a container (and hidden input).
  • style the container options as per your need using templates
  • automatically disable date-range based on disabled/readonly options.

Note: This extension depends on the kartik-v/yii2-widgets extension which in turn depends on the yiisoft/yii2-bootstrap extension. Check the composer.json for this extension's requirements and dependencies. Note: Yii 2 framework is still in active development, and until a fully stable Yii2 release, your core yii2-bootstrap packages (and its dependencies) may be updated when you install or update this extension. You may need to lock your composer package versions for your specific app, and test for extension break if you do not wish to auto update dependencies.

Demo

You can see detailed documentation and a complete demo on usage of the extension.

Installation

The preferred way to install this extension is through composer.

Either run:

$ php composer.phar require kartik-v/yii2-date-range "*"

or add:

"kartik-v/yii2-date-range": "*"

to the require section of your composer.json file.

Usage

use kartik\daterange\DateRangePicker;
echo DateRangePicker::widget([
    'model'=>$model,
    'attribute'=>'datetime_range',
    'convertFormat'=>true,
    'pluginOptions'=>[
        'timePicker'=>true,
        'timePickerIncrement'=>30,
        'format'=>'Y-m-d h:i A'
    ]
]);

Report

License

yii2-date-range is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.

Resources

Total 1 comment

#17756 report it
ThePr0f3550r at 2014/07/19 10:52pm
amazing

your extension always amazing

Leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet