karatae99 / yii2-date-picker-thai-widget
Bootstrap DatePicker Thai Buddhist-Era (B.E.) widget for Yii2.
Installs: 1 250
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 1
Type:yii2-extension
Requires
- bower-asset/bootstrap-datepicker: 1.7.0
- yiisoft/yii2: >=2.0.9
- yiisoft/yii2-bootstrap: *
This package is not auto-updated.
Last update: 2024-12-22 08:13:52 UTC
README
This is thai buddhist calendar datepicker of Yii2 extension.
modified from (https://github.com/2amigos/yii2-date-picker-widget).
Installation
The preferred way to install this extension is through composer.
Either run
$ composer require karatae99/yii2-date-picker-thai-widget "~1.0"
or add
"karatae99/yii2-date-picker-thai-widget" : "~1.0"
to the require section of your application's composer.json
file.
Usage
DatePicker
This widget renders a Bootstrap DatePicker input control. Best suitable for model with date string attribute.
Example of use with a form
There are two ways of using it, with an ActiveForm
instance or as a widget setting up its model
and attribute
.
<?php use karatae99\datepicker\DatePicker; // as a widget ?> <?= DatePicker::widget([ 'model' => $model, 'attribute' => 'date', 'template' => '{addon}{input}', 'language' => 'th', //<-- Thai B.E. 'clientOptions' => [ 'autoclose' => true, 'format' => 'dd/mm/yyyy' //<-- Thai B.E. ] ]);?> <?php // with an ActiveForm instance ?> <?= $form->field($model, 'date')->widget( DatePicker::className(), [ // inline too, not bad 'inline' => true, // modify template for custom rendering 'template' => '<div class="well well-sm" style="background-color: #fff; width:250px">{input}</div>', 'language' => 'th', //<-- Thai B.E. 'clientOptions' => [ 'autoclose' => true, 'format' => 'dd/mm/yyyy' //<-- Thai B.E. ] ]);?>
Example of use without a model
<?php use karatae99\datepicker\DatePicker; ?> <?= DatePicker::widget([ 'name' => 'Test', 'value' => '20/03/2561', 'template' => '{addon}{input}', 'language' => 'th', //<-- Thai B.E. 'clientOptions' => [ 'autoclose' => true, 'format' => 'dd/mm/yyyy' //<-- Thai B.E. ] ]);?>
DateRangePicker
This widget renders a Bootstrap DateRangePicker Input control.
Example of use with a form
The following example works with a model that has two attributes named date_from
and date_to
.
<?php use karatae99\datepicker\DateRangePicker; ?> <?= $form->field($model, 'date_from')->widget(DateRangePicker::className(), [ 'attributeTo' => 'date_to', 'form' => $form, // best for correct client validation 'language' => 'th', //<-- Thai B.E. 'size' => 'lg', 'clientOptions' => [ 'autoclose' => true, 'format' => 'dd/mm/yyyy' //<-- Thai B.E. ] ]);?>
Further Information
Please, check the Bootstrap DatePicker site documentation for further information about its configuration options.
License
The BSD License (BSD). Please see License File for more information.