Skip to content

webasoo/yii2-jalali-datepicker

 
 

Repository files navigation

Jalali Bootstrap DatePicker Widget for Yii2

Renders a Jalali Bootstrap DatePicker plugin.

Installation

The preferred way to install this extension is through composer.

Either run

composer require mrlco/yii2-jalali-datepicker:~0.1.0

or add

"mrlco/yii2-jalali-datepicker" : "~0.1.0"

to the require section of your application's composer.json file.

Usage

DatePicker

This widget renders a Bootstrap Persian 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 mrlco\datepicker\Datepicker;
?>
<?php
// as a widget
?>
<?= Datepicker::widget([
    'model' => $model,
    'attribute' => 'date',
    'template' => '{addon}{input}',
        'clientOptions' => [
            'format' => 'YYYY/MM/DD'
        ]
]);?>
<?php 
// with an ActiveForm instance 
?>
<?= $form->field($model, 'date')->widget(
    Datepicker::className(), [
        'inline' => true,
        'template' => '<div class="well well-sm" style="background-color: #fff; width:250px">{input}</div>',
        'clientOptions' => [
            'format' => 'YYYY/MM/DD'
        ]
]);?>

Example of use without a model

<?php
use mrlco\datepicker\Datepicker;
?>
<?= Datepicker::widget([
    'name' => 'Test',
    'value' => '1394/03/23',
    'template' => '{addon}{input}',
        'clientOptions' => [
            'format' => 'YYYY/MM/DD'
        ]
]);?>

Credits

License

The BSD License (BSD). Please see License File for more information. )

About

Yii2 Jalali datepicker is a persian datepicker

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%