Support yearRange property for datepicker field.

This commit is contained in:
Konstantin L 2016-12-20 20:21:02 +01:00
parent 97b0bc481f
commit 15cea23308
2 changed files with 9 additions and 0 deletions

View File

@ -40,6 +40,12 @@ class DatePicker extends FormWidgetBase
*/
public $maxDate = null;
/**
* @var string number of years either side or array of upper/lower range
* eg: 10 or [1900,1999]
*/
public $yearRange = null;
//
// Object properties
//
@ -59,6 +65,7 @@ class DatePicker extends FormWidgetBase
'mode',
'minDate',
'maxDate',
'yearRange',
]);
$this->mode = strtolower($this->mode);
@ -104,6 +111,7 @@ class DatePicker extends FormWidgetBase
$this->vars['mode'] = $this->mode;
$this->vars['minDate'] = $this->minDate;
$this->vars['maxDate'] = $this->maxDate;
$this->vars['yearRange'] = $this->yearRange;
$this->vars['format'] = $this->format;
$this->vars['formatMoment'] = $this->getDateFormatMoment();
$this->vars['formatAlias'] = $this->getDateFormatAlias();

View File

@ -13,6 +13,7 @@
<?php if ($formatMoment): ?>data-format="<?= $formatMoment ?>"<?php endif ?>
<?php if ($minDate): ?>data-min-date="<?= $minDate ?>"<?php endif ?>
<?php if ($maxDate): ?>data-max-date="<?= $maxDate ?>"<?php endif ?>
<?php if ($yearRange): ?>data-year-range="<?= $yearRange ?>"<?php endif ?>
>
<?php if ($mode == 'date'): ?>