vendor/symfony/form/Extension/Core/Type/BirthdayType.php line 18

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Form\Extension\Core\Type;
  11. use Symfony\Component\Form\AbstractType;
  12. use Symfony\Component\OptionsResolver\Options;
  13. use Symfony\Component\OptionsResolver\OptionsResolver;
  14. class BirthdayType extends AbstractType
  15. {
  16.     /**
  17.      * {@inheritdoc}
  18.      */
  19.     public function configureOptions(OptionsResolver $resolver)
  20.     {
  21.         $resolver->setDefaults([
  22.             'years' => range((int) date('Y') - 120date('Y')),
  23.             'invalid_message' => function (Options $options$previousValue) {
  24.                 return ($options['legacy_error_messages'] ?? true)
  25.                     ? $previousValue
  26.                     'Please enter a valid birthdate.';
  27.             },
  28.         ]);
  29.         $resolver->setAllowedTypes('years''array');
  30.     }
  31.     /**
  32.      * {@inheritdoc}
  33.      */
  34.     public function getParent()
  35.     {
  36.         return DateType::class;
  37.     }
  38.     /**
  39.      * {@inheritdoc}
  40.      */
  41.     public function getBlockPrefix()
  42.     {
  43.         return 'birthday';
  44.     }
  45. }