mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
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:
commit
54b4223660
@ -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}
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user