added code to use custom date_pattern
This commit is contained in:
parent
a414e56881
commit
dd104bc8c0
@ -83,8 +83,7 @@ class DateType extends AbstractType
|
||||
|
||||
$builder
|
||||
->setAttribute('formatter', $formatter)
|
||||
->setAttribute('widget', $options['widget'])
|
||||
;
|
||||
->setAttribute('widget', $options['widget']);
|
||||
}
|
||||
|
||||
public function buildViewBottomUp(FormView $view, FormInterface $form)
|
||||
@ -93,6 +92,8 @@ class DateType extends AbstractType
|
||||
|
||||
if ($view->hasChildren()) {
|
||||
|
||||
//if custom date_pattern is set then use it or else use the the formatter or the default pattern
|
||||
if (!$pattern = $form->getAttribute('date_pattern')) {
|
||||
$pattern = $form->getAttribute('formatter')->getPattern();
|
||||
|
||||
// set right order with respect to locale (e.g.: de_DE=dd.MM.yy; en_US=M/d/yy)
|
||||
@ -103,6 +104,7 @@ class DateType extends AbstractType
|
||||
// default fallback
|
||||
$pattern = '{{ year }}-{{ month }}-{{ day }}';
|
||||
}
|
||||
}
|
||||
|
||||
$view->set('date_pattern', $pattern);
|
||||
}
|
||||
|
Reference in New Issue
Block a user