vendor/symfony/form/Extension/Core/Type/HiddenType.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 HiddenType extends AbstractType
  15. {
  16.     /**
  17.      * {@inheritdoc}
  18.      */
  19.     public function configureOptions(OptionsResolver $resolver)
  20.     {
  21.         $resolver->setDefaults([
  22.             // hidden fields cannot have a required attribute
  23.             'required' => false,
  24.             // Pass errors to the parent
  25.             'error_bubbling' => true,
  26.             'compound' => false,
  27.             'invalid_message' => function (Options $options$previousValue) {
  28.                 return ($options['legacy_error_messages'] ?? true)
  29.                     ? $previousValue
  30.                     'The hidden field is invalid.';
  31.             },
  32.         ]);
  33.     }
  34.     /**
  35.      * {@inheritdoc}
  36.      */
  37.     public function getBlockPrefix()
  38.     {
  39.         return 'hidden';
  40.     }
  41. }