src/Form/Type/Search/SearchType.php line 23

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of Monsieur Biz' Search plugin for Sylius.
  4.  *
  5.  * (c) Monsieur Biz <sylius@monsieurbiz.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE.txt
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace App\Form\Type\Search;
  12. use Symfony\Component\Form\AbstractType;
  13. use Symfony\Component\Form\Extension\Core\Type\SearchType as SymfonySearchType;
  14. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  15. use Symfony\Component\Form\FormBuilderInterface;
  16. use Symfony\Component\Validator\Constraints\NotBlank;
  17. use Symfony\Component\Validator\Constraints\Required;
  18. class SearchType extends AbstractType
  19. {
  20.     public function buildForm(FormBuilderInterface $builder, array $options): void
  21.     {
  22.         $builder
  23.             ->add('query'SymfonySearchType::class, [
  24.                 'required' => true,
  25.                 'label' => 'monsieurbiz_searchplugin.form.query',
  26.                 'attr' => [
  27.                     'placeholder' => 'monsieurbiz_searchplugin.form.query_placeholder',
  28.                     'autocomplete' => 'off'
  29.                 ],
  30.                 'constraints' => [
  31.                     new NotBlank(),
  32.                     new Required(),
  33.                 ],
  34.             ])
  35.             ->add('submit'SubmitType::class, [
  36.                 'attr' => ['class' => 'submit'],
  37.                 'label' => 'monsieurbiz_searchplugin.form.submit',
  38.             ])
  39.         ;
  40.     }
  41.     /**
  42.      * @inheritdoc
  43.      */
  44.     public function getBlockPrefix()
  45.     {
  46.         return 'monsieurbiz_searchplugin_search';
  47.     }
  48. }