2017 © Pedro Peláez
 

yii2-extension date-picker-masked-widget

Bootstrap DatePicker widget for Yii2 along with the Yii input mask functionality.

image

dianakaal/date-picker-masked-widget

Bootstrap DatePicker widget for Yii2 along with the Yii input mask functionality.

  • Thursday, March 31, 2016
  • by dianakaal
  • Repository
  • 1 Watchers
  • 0 Stars
  • 98 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

DatePickerMaskedWidget for Yii2

A combination between the bootstrap datepicker and the input mask. In other words you can have a date picker as well as an input mask simultaneously in the same field., (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

composer require dianakaal/date-picker-masked-widget="*"

or add, (*4)

"dianakaal/date-picker-masked-widget": "*"

to the require section of your application's composer.json file., (*5)

USAGE

Plain Date Picker

------> WITH A MODEL <------, (*6)

as a plain widget, (*7)

<?php
use dianakaal\DatePickerMaskedWidget\DatePickerMaskedWidget;
?>
<?=
    DatePickerMaskedWidget::widget([
            'model' => '$modelName',
            'value' => '30-16-2016'
            'attribute' => false,
            'template' => '{addon}{input}',
            'language' => 'fi',
            'clientOptions' => [
            'autoclose' => true,
            'clearBtn' => true,
            'format' => 'dd.mm.yyyy',
            'todayBtn' => 'linked',
            'todayHighlight' => 'true',
            'weekStart' => '1',
            'calendarWeeks' => 'true',
            'orientation' => 'top left',
        ],
        'maskOptions' => [
            'alias' => 'dd.mm.yyyy'
        ],
    ]);
?>

with an ActiveForm, (*8)

=
    $form->field($model, 'nameOfField')->widget(
        DatePickerMaskedWidget::className(), [
            'inline' => false,
            'template' => '{addon}{input}',
            'language' => 'fi',
            'clientOptions' => [
                'autoclose' => true,
                'clearBtn' => true,
                'format' => 'dd.mm.yyyy',
                'todayBtn' => 'linked',
                'todayHighlight' => 'true',
                'weekStart' => '1',
                'calendarWeeks' => 'true',
                'orientation' => 'top left',
            ],
            'maskOptions' => [
                'alias' => 'dd.mm.yyyy'
            ],

        ]
    );
?>

------> WITHOUT A MODEL <------, (*9)


=
    DatePickerMaskedWidget::widget([
        'name' => 'test',
        'value' => '30-16-2016'
        'attribute' => false,
        'template' => '{addon}{input}',
        'language' => 'fi',
        'clientOptions' => [
            'autoclose' => true,
            'clearBtn' => true,
            'format' => 'dd.mm.yyyy',
            'todayBtn' => 'linked',
            'todayHighlight' => 'true',
            'weekStart' => '1',
            'calendarWeeks' => 'true',
            'orientation' => 'top left',
        ],
        'maskOptions' => [
            'alias' => 'dd.mm.yyyy'
        ],
    ]);
?>

####Date Range Picker

------> WITHOUT A MODEL <------, (*10)

<?php
use dianakaal\DatePickerMaskedWidget\DateRangePickerMaskedWidget;
?>
<?=
    DateRangePickerMaskedWidget::widget([
        'name' => 'test',
        'value' => '30-16-2016'
        'attribute' => false,
        'template' => '{addon}{input}',
        'language' => 'fi',
        'clientOptions' => [
            'autoclose' => true,
            'clearBtn' => true,
            'format' => 'dd.mm.yyyy',
            'todayBtn' => 'linked',
            'todayHighlight' => 'true',
            'weekStart' => '1',
            'calendarWeeks' => 'true',
            'orientation' => 'top left',
        ],
        'maskOptions' => [
            'alias' => 'dd.mm.yyyy'
        ],
    ]);
?>

------> WITH A MODEL <------, (*11)

<?php
use dianakaal\DatePickerMaskedWidget\DateRangePickerMaskedWidget;
?>
<?=
    $form->field($model, 'startDate')->widget(DateRangePickerMaskedWidget::className(), [
        'attributeTo' => 'endDate',
        'form' => $form, // best for correct client validation
        'language' => 'es',
        'size' => 'lg',
        'clientOptions' => [
            'autoclose' => true,
            'format' => 'dd-M-yyyy'
        ]
    ]);
?>

Further Information

Please, check the Bootstrap DatePicker site documentation for further information about its configuration options. Or the Masked Input Demo for examples on how to use the masks. Read the source files in order to understand how the widget works., (*12)

License

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

Credits

The Versions

31/03 2016

dev-master

9999999-dev

Bootstrap DatePicker widget for Yii2 along with the Yii input mask functionality.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Avatar dianakaal

extension yii2 yii yii 2 widget datepicker inputmask masked input