Merge pull request #1475 from patrickward/develop

Allow minDate/maxDate to be entered in date format for DatePicker. Fixes #909.
This commit is contained in:
Samuel Georges 2015-10-17 08:42:45 +11:00
commit 54b4223660

View File

@ -46,15 +46,35 @@ class DatePicker extends FormWidgetBase
*/
public function init()
{
$this->fillFromConfig([
'mode',
'minDate',
'maxDate',
]);
$this->fillDatesFromConfig();
$this->fillFromConfig(['mode']);
$this->mode = strtolower($this->mode);
}
/**
* Transfers minDate and maxDate config values stored inside the
* $config property directly on to the root object properties.
*
* This method checks for Yaml parsed dates that have been converted
* into integer timestamps via the Symfony Yaml parser and converts them
* back into strings for use with the datepicker.
*
* @param array $properties
* @return void
*/
protected function fillDatesFromConfig()
{
foreach(['minDate', 'maxDate'] as $property) {
$this->{$property} = $this->getConfig($property, $this->{$property});
if (is_integer($this->{$property})) {
$this->{$property} = date('Y-m-d', $this->{$property});
}
}
}
/**
* {@inheritDoc}
*/