1: <?php
2: namespace TIC\FormBundle\Form\Type;
3:
4: #use Symfony\Component\Form\AbstractType as BaseType;
5: use TIC\FormBundle\Base\TICWidgetType as BaseType;
6:
7: use Symfony\Component\OptionsResolver\OptionsResolver;
8:
9: /**
10: * Sélecteur de date de naissance (popup avec calendrier).
11: * Intégration du composant JS bootstrap-datetimepicker
12: */
13: class BirthdayType extends BaseType
14: {
15: # protected $form_parent = \Symfony\Component\Form\Extension\Core\Type\DateType::class;
16: protected $form_parent = DateType::class;
17: protected $default_prefix = '<calendar>';
18: protected $default_suffix = '<calendar>';
19: /** Formattage standard forcé coté PHP (transformations selon la locale laissée au composant JS) */
20: const INTERNAL_DATE_FORMAT = "yyyy-MM-dd";
21:
22:
23: /**
24: * {@inheritdoc}
25: */
26: public function configureOptions(OptionsResolver $resolver): void
27: {
28: parent::configureOptions($resolver);
29:
30: $resolver->setDefaults(array(
31: 'placeholder' => false, // true, false, String (ex: "widget_date_ph_format_d")
32: 'suffix' => true,
33:
34: # 'widget' => 'single_text',
35: # 'html5' => false,
36: # 'format' => self::INTERNAL_DATE_FORMAT,
37:
38: # 'jsformat' => 'L', // cf http://momentjs.com/docs/#/displaying/format/
39: # 'culture' => \Locale::getPrimaryLanguage(\Locale::getDefault()),
40: 'minDate' => mktime(0, 0, 0, 1, 1, date('Y')-120), // max 120 ans
41: 'maxDate' => time(), // min 0 an
42: 'viewDate' => mktime(0, 0, 0, 1, 1, date('Y')-40), // présélection ~40ans
43: 'viewMode' => 'years', // ou 'decades' ?
44: 'buttons' => array('clear','close'),
45: ));
46: }
47:
48:
49: }
50: