From 3b734da1503f21064a294ca00568ff5a32656678 Mon Sep 17 00:00:00 2001 From: Tchama Date: Tue, 15 Jan 2019 13:59:55 +0100 Subject: [PATCH] add chill custom datetime type --- Form/Type/ChillDateTimeType.php | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Form/Type/ChillDateTimeType.php diff --git a/Form/Type/ChillDateTimeType.php b/Form/Type/ChillDateTimeType.php new file mode 100644 index 000000000..71c1b2680 --- /dev/null +++ b/Form/Type/ChillDateTimeType.php @@ -0,0 +1,48 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +namespace Chill\MainBundle\Form\Type; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\DateTimeType; +use Symfony\Component\OptionsResolver\OptionsResolver; + +/** + * Display the date in a date picker. + * + * Extends the symfony `Symfony\Component\Form\Extension\Core\Type\DateType` + * to automatically create a date picker. + * + * @author Julien Fastré + */ +class ChillDateTimeType extends AbstractType +{ + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('date_widget', 'single_text') + ->setDefault('date_format', 'dd-MM-yyyy') + ->setDefault('time_widget', 'choice') + ->setDefault('html5', true) + ; + } + + public function getParent() + { + return DateTimeType::class; + } +}