src/Form/MarketFilterType.php line 50

  1. <?php
  2. namespace App\Form;
  3. use App\Entity\NftCollection;
  4. use App\Entity\TemplateCategory;
  5. use App\Entity\TemplateGenus;
  6. use Doctrine\ORM\EntityRepository;
  7. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  8. use Symfony\Component\Form\AbstractType;
  9. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  10. use Symfony\Component\Form\FormBuilderInterface;
  11. use Symfony\Component\OptionsResolver\OptionsResolver;
  12. class MarketFilterType extends AbstractType
  13. {
  14.     public function buildForm(FormBuilderInterface $builder, array $options): void
  15.     {
  16.         $builder
  17.             ->add('sort'ChoiceType::class, [
  18.                 'placeholder' => 'Sort by...',
  19.                 'required' => false,
  20.                 'choices' => [
  21.                     'Newest' => 'newest',
  22.                     'Oldest' => 'oldest',
  23.                     'Price: High to Low' => 'price_high_to_low',
  24.                     'Price: Low to High' => 'price_low_to_high',
  25.                     'Mint: High to Low' => 'mint_high_to_low',
  26.                     'Mint: Low to High' => 'mint_low_to_hight',
  27.                     'Grade: High to Low' => 'grade_high_to_low',
  28.                     'Grade: Low to High' => 'grade_low_to_high',
  29.                     'Score: High to Low' => 'score_high_to_low',
  30.                     'Score: Low to High' => 'score_low_to_high',
  31.                     'Luck: High to Low' => 'luck_high_to_low',
  32.                     'Luck: Low to High' => 'luck_low_to_high',
  33.                     'Distance: High to Low' => 'distance_high_to_low',
  34.                     'Distance: Low to High' => 'distance_low_to_high',
  35.                     'Tension: High to Low' => 'tension_high_to_low',
  36.                     'Tension: Low to High' => 'tension_low_to_high',
  37.                 ]
  38.             ])
  39.             ->add('collection'EntityType::class, [
  40.                 'placeholder' => 'All',
  41.                 'class' => NftCollection::class,
  42.                 'required' => false,
  43.             ])
  44.             ->add('genus'EntityType::class, [
  45.                 'placeholder' => 'All',
  46.                 'class' => TemplateGenus::class,
  47.                 'query_builder' => function (EntityRepository $er) {
  48.                     return $er->createQueryBuilder('tg')
  49.                         ->andWhere('tg.id IN(1,4)')
  50.                         ->orderBy('tg.name''ASC');
  51.                 },
  52.                 'required' => false,
  53.                 'choice_label' => 'name',
  54.             ])
  55.             ->add('category'EntityType::class, [
  56.                 'multiple' => true,
  57.                 'expanded' => true,
  58.                 'required' => false,
  59.                 'class' => TemplateCategory::class,
  60.                 'query_builder' => function (EntityRepository $er) {
  61.                     return $er->createQueryBuilder('tc')
  62.                         ->andWhere('tc.id IN(1,2,3,4,5,6,7)')
  63.                         ->orderBy('tc.id''ASC');
  64.                 },
  65.                 'choice_label' => 'name',
  66. //                'choices' => [
  67. //                    'Rod' => 'category_rod',
  68. //                    'Lure' => 'category_lure',
  69. //                    'Hat' => 'category_hat',
  70. //                    'Chest' => 'category_chest',
  71. //                    'Tacklebox' => 'category_tacklebox',
  72. //                    'Boots' => 'category_boots',
  73. //                    'Charm' => 'category_charm',
  74. //                ],
  75.             ])
  76. //            ->add('status', ChoiceType::class, [
  77. //                'required' => false,
  78. //                'placeholder' => 'Status...',
  79. //                'choices' => [
  80. //                    'Active' => 'status_active',
  81. //                    'Sold' => 'status_sold',
  82. //                ],
  83. //            ])
  84.         ;
  85.     }
  86.     public function configureOptions(OptionsResolver $resolver): void
  87.     {
  88.         $resolver->setDefaults([
  89.             // Configure your form options here
  90.         ]);
  91.     }
  92. }