├── CHANGELOG.md ├── src ├── DatePickerLanguageAsset.php ├── assets │ └── css │ │ └── bootstrap-daterangepicker.css ├── DateRangePickerAsset.php ├── DatePickerAsset.php ├── DatePickerTrait.php ├── DatePicker.php └── DateRangePicker.php ├── CONTRIBUTING.md ├── composer.json ├── LICENSE.md └── README.md /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 1.0.5 - 2015-04-02 4 | 5 | ## Changed 6 | - Added CHANGELOG.md file 7 | 8 | ## Fixed 9 | - Fixed asset registration bug when using form 10 | -------------------------------------------------------------------------------- /src/DatePickerLanguageAsset.php: -------------------------------------------------------------------------------- 1 | 15 | * @link http://www.ramirezcobos.com/ 16 | * @link http://www.2amigos.us/ 17 | * @package dosamigos\datepicker 18 | */ 19 | class DatePickerLanguageAsset extends AssetBundle 20 | { 21 | public $sourcePath = '@bower/bootstrap-datepicker/dist/locales'; 22 | 23 | public $depends = [ 24 | 'dosamigos\datepicker\DateRangePickerAsset' 25 | ]; 26 | } 27 | -------------------------------------------------------------------------------- /src/assets/css/bootstrap-daterangepicker.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Custom styling. Removing padding when using DateRangePicker. 3 | */ 4 | .datepicker { 5 | z-index: 1151 !important; 6 | } 7 | 8 | .datepicker-range { 9 | padding: 0 !important; 10 | border: 0 !important; 11 | text-align: left !important; 12 | } 13 | 14 | .datepicker-from { 15 | border-radius: 4px !important; 16 | border-top-right-radius: 0 !important; 17 | border-bottom-right-radius: 0 !important; 18 | text-align: left !important; 19 | } 20 | 21 | .datepicker-to { 22 | border-radius: 4px !important; 23 | border-top-left-radius: 0 !important; 24 | border-bottom-left-radius: 0 !important; 25 | text-align: left !important; 26 | } 27 | 28 | div.datepicker-range { 29 | width: 100%; 30 | } 31 | -------------------------------------------------------------------------------- /src/DateRangePickerAsset.php: -------------------------------------------------------------------------------- 1 | 15 | * @link http://www.ramirezcobos.com/ 16 | * @link http://www.2amigos.us/ 17 | * @package dosamigos\datepicker 18 | */ 19 | class DateRangePickerAsset extends AssetBundle 20 | { 21 | public $sourcePath = '@vendor/2amigos/yii2-date-picker-widget/src/assets'; 22 | 23 | public $css = [ 24 | 'css/bootstrap-daterangepicker.css' 25 | ]; 26 | 27 | public $depends = [ 28 | 'dosamigos\datepicker\DatePickerAsset' 29 | ]; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/DatePickerAsset.php: -------------------------------------------------------------------------------- 1 | 15 | * @link http://www.ramirezcobos.com/ 16 | * @link http://www.2amigos.us/ 17 | * @package dosamigos\datepicker 18 | */ 19 | class DatePickerAsset extends AssetBundle 20 | { 21 | public $sourcePath = '@bower/bootstrap-datepicker/dist'; 22 | 23 | public $css = [ 24 | 'css/bootstrap-datepicker3.css', 25 | ]; 26 | 27 | public $js = [ 28 | 'js/bootstrap-datepicker.js' 29 | ]; 30 | 31 | public $depends = [ 32 | 'yii\bootstrap\BootstrapPluginAsset' 33 | ]; 34 | } 35 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | We accept contributions via Pull Requests on [Github](https://github.com/2amigos/yii2-datepicker-widget). 6 | 7 | 8 | ## Pull Requests 9 | 10 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). 11 | 12 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 13 | 14 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 15 | 16 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 17 | 18 | - **Create feature branches** - Don't ask us to pull from your master branch. 19 | 20 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 21 | 22 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting. 23 | 24 | 25 | ## Running Tests 26 | 27 | ``` bash 28 | $ phpunit 29 | ``` 30 | 31 | 32 | **Happy coding**! 33 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "2amigos/yii2-date-picker-widget", 3 | "description": "Bootstrap DatePicker widget for Yii2.", 4 | "type": "yii2-extension", 5 | "keywords": [ 6 | "2amigos", 7 | "yii", 8 | "yii2", 9 | "yii 2", 10 | "extension", 11 | "widget", 12 | "datepicker" 13 | ], 14 | "homepage": "http://yiiwheels.com/extension/bootstrap-datepicker", 15 | "license": "BSD-3-Clause", 16 | "authors": [ 17 | { 18 | "name": "2amigOS! Consulting Group", 19 | "email": "hola@2amigos.us", 20 | "homepage": "http://2amigos.us", 21 | "role": "Developer" 22 | } 23 | ], 24 | "support": { 25 | "issues": "https://github.com/2amigos/yii2-date-picker-widget/issues", 26 | "source": "https://github.com/2amigos/yii2-date-picker-widget" 27 | }, 28 | "require": { 29 | "yiisoft/yii2": ">=2.0.9", 30 | "yiisoft/yii2-bootstrap": "*", 31 | "bower-asset/bootstrap-datepicker": "1.7.0" 32 | }, 33 | "require-dev": { 34 | "phpunit/phpunit": "4.*" 35 | }, 36 | "autoload": { 37 | "psr-4": { 38 | "dosamigos\\datepicker\\": "src" 39 | } 40 | }, 41 | "extra": { 42 | "branch-alias": { 43 | "dev-master": "1.0-dev" 44 | }, 45 | "asset-installer-paths": { 46 | "bower-asset-library": "vendor/bower" 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/DatePickerTrait.php: -------------------------------------------------------------------------------- 1 | 13 | * @link http://www.ramirezcobos.com/ 14 | * @link http://www.2amigos.us/ 15 | * @package dosamigos\datepicker 16 | */ 17 | trait DatePickerTrait 18 | { 19 | /** 20 | * @var string the language to use 21 | */ 22 | public $language; 23 | /** 24 | * @var array the options for the Bootstrap DatePicker plugin. 25 | * Please refer to the Bootstrap DatePicker plugin Web page for possible options. 26 | * @see http://bootstrap-datepicker.readthedocs.org/en/release/options.html 27 | */ 28 | public $clientOptions = []; 29 | /** 30 | * @var array the event handlers for the underlying Bootstrap DatePicker plugin. 31 | * Please refer to the [DatePicker](http://bootstrap-datepicker.readthedocs.org/en/release/events.html) plugin 32 | * Web page for possible events. 33 | */ 34 | public $clientEvents = []; 35 | /** 36 | * @var string the size of the input ('lg', 'md', 'sm', 'xs') 37 | */ 38 | public $size; 39 | /** 40 | * @var array HTML attributes to render on the container 41 | */ 42 | public $containerOptions = []; 43 | } 44 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The BSD License (BSD) 2 | 3 | Copyright (c) 2013-2015, 2amigOS! Consulting Group LLC. 4 | 5 | > Redistribution and use in source and binary forms, with or without modification, 6 | > are permitted provided that the following conditions are met: 7 | > 8 | > Redistributions of source code must retain the above copyright notice, this 9 | > list of conditions and the following disclaimer. 10 | > 11 | > Redistributions in binary form must reproduce the above copyright notice, this 12 | > list of conditions and the following disclaimer in the documentation and/or 13 | > other materials provided with the distribution. 14 | > 15 | > Neither the name of 2amigOS! Consulting Group, LLC. nor the names of its 16 | > contributors may be used to endorse or promote products derived from 17 | > this software without specific prior written permission. 18 | > 19 | >THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | >ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | >WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | >DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | >ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | >(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | >LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | >ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | >(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | >SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /src/DatePicker.php: -------------------------------------------------------------------------------- 1 | 17 | * @link http://www.ramirezcobos.com/ 18 | * @link http://www.2amigos.us/ 19 | * @package dosamigos\datepicker 20 | */ 21 | class DatePicker extends InputWidget 22 | { 23 | use DatePickerTrait; 24 | 25 | /** 26 | * @var string the addon markup if you wish to display the input as a component. If you don't wish to render as a 27 | * component then set it to null or false. 28 | */ 29 | public $addon = ''; 30 | /** 31 | * @var string the template to render the input. 32 | */ 33 | public $template = '{input}{addon}'; 34 | /** 35 | * @var bool whether to render the input as an inline calendar 36 | */ 37 | public $inline = false; 38 | 39 | /** 40 | * @inheritdoc 41 | */ 42 | public function init() 43 | { 44 | parent::init(); 45 | 46 | if ($this->inline) { 47 | $this->options['readonly'] = 'readonly'; 48 | Html::addCssClass($this->options, 'text-center'); 49 | } 50 | if ($this->size) { 51 | Html::addCssClass($this->options, 'input-' . $this->size); 52 | Html::addCssClass($this->containerOptions, 'input-group-' . $this->size); 53 | } 54 | Html::addCssClass($this->options, 'form-control'); 55 | Html::addCssClass($this->containerOptions, 'input-group date'); 56 | } 57 | 58 | /** 59 | * @inheritdoc 60 | */ 61 | public function run() 62 | { 63 | 64 | $input = $this->hasModel() 65 | ? Html::activeTextInput($this->model, $this->attribute, $this->options) 66 | : Html::textInput($this->name, $this->value, $this->options); 67 | 68 | if ($this->inline) { 69 | $input .= '
'; 70 | } 71 | if ($this->addon && !$this->inline) { 72 | $addon = Html::tag('span', $this->addon, ['class' => 'input-group-addon']); 73 | $input = strtr($this->template, ['{input}' => $input, '{addon}' => $addon]); 74 | $input = Html::tag('div', $input, $this->containerOptions); 75 | } 76 | if ($this->inline) { 77 | $input = strtr($this->template, ['{input}' => $input, '{addon}' => '']); 78 | } 79 | echo $input; 80 | 81 | $this->registerClientScript(); 82 | } 83 | 84 | /** 85 | * Registers required script for the plugin to work as DatePicker 86 | */ 87 | public function registerClientScript() 88 | { 89 | $js = []; 90 | $view = $this->getView(); 91 | 92 | // @codeCoverageIgnoreStart 93 | if ($this->language !== null && $this->language !== 'en') { 94 | $this->clientOptions['language'] = $this->language; 95 | DatePickerLanguageAsset::register($view)->js[] = 'bootstrap-datepicker.' . $this->language . '.min.js'; 96 | } else { 97 | DatePickerAsset::register($view); 98 | } 99 | // @codeCoverageIgnoreEnd 100 | 101 | $id = $this->options['id']; 102 | $selector = ";jQuery('#$id')"; 103 | 104 | if ($this->addon || $this->inline) { 105 | $selector .= ".parent()"; 106 | } 107 | 108 | $options = !empty($this->clientOptions) ? Json::encode($this->clientOptions) : ''; 109 | 110 | if ($this->inline) { 111 | $this->clientEvents['changeDate'] = "function (e){ jQuery('#$id').val(e.format());}"; 112 | } 113 | 114 | $js[] = "$selector.datepicker($options);"; 115 | 116 | if (!empty($this->clientEvents)) { 117 | foreach ($this->clientEvents as $event => $handler) { 118 | $js[] = "$selector.on('$event', $handler);"; 119 | } 120 | } 121 | $view->registerJs(implode("\n", $js)); 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Bootstrap DatePicker Widget for Yii2 2 | ==================================== 3 | 4 | [![Latest Version](https://img.shields.io/github/tag/2amigos/yii2-date-picker-widget.svg?style=flat-square&label=release)](https://github.com/2amigos/yii2-date-picker-widget/tags) 5 | [![Software License](https://img.shields.io/badge/license-BSD-brightgreen.svg?style=flat-square)](LICENSE.md) 6 | [![Build Status](https://img.shields.io/travis/2amigos/yii2-date-picker-widget/master.svg?style=flat-square)](https://travis-ci.org/2amigos/yii2-date-picker-widget) 7 | [![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/2amigos/yii2-date-picker-widget.svg?style=flat-square)](https://scrutinizer-ci.com/g/2amigos/yii2-date-picker-widget/code-structure) 8 | [![Quality Score](https://img.shields.io/scrutinizer/g/2amigos/yii2-date-picker-widget.svg?style=flat-square)](https://scrutinizer-ci.com/g/2amigos/yii2-date-picker-widget) 9 | [![Total Downloads](https://img.shields.io/packagist/dt/2amigos/yii2-date-picker-widget.svg?style=flat-square)](https://packagist.org/packages/2amigos/yii2-date-picker-widget) 10 | 11 | 12 | Renders a [Bootstrap DatePicker plugin](http://bootstrapformhelpers.com/datepicker/). 13 | 14 | Installation 15 | ------------ 16 | The preferred way to install this extension is through [composer](http://getcomposer.org/download/). 17 | 18 | Either run 19 | 20 | ```bash 21 | $ composer require 2amigos/yii2-date-picker-widget:~1.0 22 | ``` 23 | or add 24 | 25 | ```json 26 | "2amigos/yii2-date-picker-widget" : "~1.0" 27 | ``` 28 | 29 | to the require section of your application's `composer.json` file. 30 | 31 | Usage 32 | ----- 33 | The widget comes in two flavors: 34 | 35 | - DatePicker 36 | - DateRangePicker 37 | 38 | **DatePicker** 39 | 40 | This widget renders a Bootstrap DatePicker input control. Best suitable for model with date string attribute. 41 | 42 | ***Example of use with a form*** 43 | There are two ways of using it, with an `ActiveForm` instance or as a widget setting up its `model` and `attribute`. 44 | 45 | ```php 46 | 51 | 52 | $model, 54 | 'attribute' => 'date', 55 | 'template' => '{addon}{input}', 56 | 'clientOptions' => [ 57 | 'autoclose' => true, 58 | 'format' => 'dd-M-yyyy' 59 | ] 60 | ]);?> 61 | 62 | 65 | field($model, 'date')->widget( 66 | DatePicker::className(), [ 67 | // inline too, not bad 68 | 'inline' => true, 69 | // modify template for custom rendering 70 | 'template' => '
{input}
', 71 | 'clientOptions' => [ 72 | 'autoclose' => true, 73 | 'format' => 'dd-M-yyyy' 74 | ] 75 | ]);?> 76 | ``` 77 | ***Example of use without a model*** 78 | 79 | ```php 80 | 83 | 'Test', 85 | 'value' => '02-16-2012', 86 | 'template' => '{addon}{input}', 87 | 'clientOptions' => [ 88 | 'autoclose' => true, 89 | 'format' => 'dd-M-yyyy' 90 | ] 91 | ]);?> 92 | ``` 93 | **DateRangePicker** 94 | 95 | This widget renders a Bootstrap DateRangePicker Input control. 96 | 97 | ***Example of use with a form*** 98 | The following example works with a model that has two attributes named `date_from` and `date_to`. 99 | 100 | ```php 101 | 104 | field($tour, 'date_from')->widget(DateRangePicker::className(), [ 105 | 'attributeTo' => 'date_to', 106 | 'form' => $form, // best for correct client validation 107 | 'language' => 'es', 108 | 'size' => 'lg', 109 | 'clientOptions' => [ 110 | 'autoclose' => true, 111 | 'format' => 'dd-M-yyyy' 112 | ] 113 | ]);?> 114 | ``` 115 | ***Example of use without a model*** 116 | 117 | ```php 118 | 121 | 'date_from', 123 | 'value' => '02-16-2012', 124 | 'nameTo' => 'name_to', 125 | 'valueTo' => '02-20-2012' 126 | ]);?> 127 | ``` 128 | 129 | Testing 130 | ------- 131 | 132 | To test the extension, is better to clone this repository on your computer. After, go to the extensions folder and do 133 | the following (assuming you have `composer` installed on your computer): 134 | 135 | ```bash 136 | $ composer install --no-interaction --prefer-source --dev 137 | ``` 138 | Once all required libraries are installed then do: 139 | 140 | ```bash 141 | $ vendor/bin/phpunit 142 | ``` 143 | 144 | I would recommend to have `phpunit` globally installed together with `xdebug` so you can have code coverage analysis too. 145 | 146 | Further Information 147 | ------------------- 148 | Please, check the [Bootstrap DatePicker site](http://bootstrap-datepicker.readthedocs.io/en/latest/) documentation for further information about its configuration options. 149 | 150 | Contributing 151 | ------------ 152 | 153 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 154 | 155 | Credits 156 | ------- 157 | 158 | - [Antonio Ramirez](https://github.com/tonydspaniard) 159 | - [All Contributors](../../contributors) 160 | 161 | License 162 | ------- 163 | 164 | The BSD License (BSD). Please see [License File](LICENSE.md) for more information. 165 | 166 | 167 | > [![2amigOS!](http://www.gravatar.com/avatar/55363394d72945ff7ed312556ec041e0.png)](http://www.2amigos.us) 168 | Web development has never been so fun! 169 | [www.2amigos.us](http://www.2amigos.us) 170 | -------------------------------------------------------------------------------- /src/DateRangePicker.php: -------------------------------------------------------------------------------- 1 | 18 | * @link http://www.ramirezcobos.com/ 19 | * @link http://www.2amigos.us/ 20 | * @package dosamigos\datepicker 21 | */ 22 | class DateRangePicker extends InputWidget 23 | { 24 | use DatePickerTrait; 25 | 26 | /** 27 | * @var string the attribute name for date range (to Date) 28 | */ 29 | public $attributeTo; 30 | /** 31 | * @var string the name for date range (to Date) 32 | */ 33 | public $nameTo; 34 | /** 35 | * @var string the value for date range (to Date value) 36 | */ 37 | public $valueTo; 38 | /** 39 | * @var array HTML attributes for the date to input 40 | */ 41 | public $optionsTo; 42 | /** 43 | * @var string the label to. Defaults to 'to'. 44 | */ 45 | public $labelTo = 'to'; 46 | /** 47 | * @var \yii\widgets\ActiveForm useful for client validation of attributeTo 48 | */ 49 | public $form; 50 | /** 51 | * @var string the template to render. Used internally. 52 | */ 53 | protected $_template = '{inputFrom}{labelTo}{inputTo}'; 54 | 55 | 56 | /** 57 | * @inheritdoc 58 | * @throws \yii\base\InvalidConfigException 59 | */ 60 | public function init() 61 | { 62 | parent::init(); 63 | if ((!$this->hasModel() && $this->nameTo === null) || ($this->hasModel() && $this->attributeTo === null)) { 64 | // @codeCoverageIgnoreStart 65 | throw new InvalidConfigException("Either 'nameTo', or 'model' and 'attributeTo' properties must be specified."); 66 | // @codeCoverageIgnoreEnd 67 | } 68 | if ($this->size) { 69 | Html::addCssClass($this->options, 'input-' . $this->size); 70 | Html::addCssClass($this->optionsTo, 'input-' . $this->size); 71 | Html::addCssClass($this->containerOptions, 'input-group-' . $this->size); 72 | } 73 | Html::addCssClass($this->containerOptions, 'input-group input-daterange'); 74 | Html::addCssClass($this->options, 'form-control'); 75 | Html::addCssClass($this->optionsTo, 'form-control'); 76 | } 77 | 78 | /** 79 | * @inheritdoc 80 | */ 81 | public function run() 82 | { 83 | if ($this->form) { 84 | Html::addCssClass($this->options, 'datepicker-from'); 85 | Html::addCssClass($this->optionsTo, 'datepicker-to'); 86 | $inputFrom = $this->form->field( 87 | $this->model, 88 | $this->attribute, 89 | [ 90 | 'template' => '{input}{error}', 91 | 'options' => ['class' => 'input-group datepicker-range'], 92 | ] 93 | )->textInput($this->options); 94 | $inputTo = $this->form->field( 95 | $this->model, 96 | $this->attributeTo, 97 | [ 98 | 'template' => '{input}{error}', 99 | 'options' => ['class' => 'input-group datepicker-range'], 100 | ] 101 | )->textInput($this->optionsTo); 102 | } else { 103 | $inputFrom = $this->hasModel() 104 | ? Html::activeTextInput($this->model, $this->attribute, $this->options) 105 | : Html::textInput($this->name, $this->value, $this->options); 106 | $inputTo = $this->hasModel() 107 | ? Html::activeTextInput($this->model, $this->attributeTo, $this->optionsTo) 108 | : Html::textInput($this->nameTo, $this->valueTo, $this->optionsTo); 109 | } 110 | echo Html::tag( 111 | 'div', 112 | strtr( 113 | $this->_template, 114 | ['{inputFrom}' => $inputFrom, '{labelTo}' => $this->labelTo, '{inputTo}' => $inputTo] 115 | ), $this->containerOptions); 116 | 117 | $this->registerClientScript(); 118 | } 119 | 120 | /** 121 | * Registers required script for the plugin to work as DateRangePicker 122 | */ 123 | public function registerClientScript() 124 | { 125 | $js = []; 126 | $view = $this->getView(); 127 | 128 | // @codeCoverageIgnoreStart 129 | if($this->language !== null) { 130 | $this->clientOptions['language'] = $this->language; 131 | DatePickerLanguageAsset::register($view)->js[] = 'bootstrap-datepicker.' . $this->language . '.min.js'; 132 | } else { 133 | DateRangePickerAsset::register($view); 134 | } 135 | // @codeCoverageIgnoreEnd 136 | 137 | $id = $this->options['id']; 138 | $selector = ";jQuery('#$id').parent()"; 139 | if($this->form && $this->hasModel()) { 140 | // @codeCoverageIgnoreStart 141 | $selector .= '.parent()'; 142 | $class = "field-" . Html::getInputId($this->model, $this->attribute); 143 | $js[] = "$selector.closest('.$class').removeClass('$class');"; 144 | // @codeCoverageIgnoreEnd 145 | } 146 | 147 | $options = !empty($this->clientOptions) ? Json::encode($this->clientOptions) : ''; 148 | 149 | $js[] = "$selector.datepicker($options);"; 150 | 151 | // @codeCoverageIgnoreStart 152 | if (!empty($this->clientEvents)) { 153 | foreach ($this->clientEvents as $event => $handler) { 154 | $js[] = "$selector.on('$event', $handler);"; 155 | } 156 | } 157 | // @codeCoverageIgnoreEnd 158 | $view->registerJs(implode("\n", $js)); 159 | } 160 | 161 | } 162 | --------------------------------------------------------------------------------