src/Form/MarketFilterType.php line 64
<?php
namespace App\Form;
use App\Entity\NftCollection;
use App\Entity\TemplateCategory;
use App\Entity\TemplateGenus;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class MarketFilterType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('sort', ChoiceType::class, [
'placeholder' => 'Sort by...',
'required' => false,
'choices' => [
'Newest' => 'newest',
'Oldest' => 'oldest',
'Price: High to Low' => 'price_high_to_low',
'Price: Low to High' => 'price_low_to_high',
'Mint: High to Low' => 'mint_high_to_low',
'Mint: Low to High' => 'mint_low_to_hight',
'Grade: High to Low' => 'grade_high_to_low',
'Grade: Low to High' => 'grade_low_to_high',
'Score: High to Low' => 'score_high_to_low',
'Score: Low to High' => 'score_low_to_high',
'Luck: High to Low' => 'luck_high_to_low',
'Luck: Low to High' => 'luck_low_to_high',
'Distance: High to Low' => 'distance_high_to_low',
'Distance: Low to High' => 'distance_low_to_high',
'Tension: High to Low' => 'tension_high_to_low',
'Tension: Low to High' => 'tension_low_to_high',
]
])
->add('collection', EntityType::class, [
'placeholder' => 'All',
'class' => NftCollection::class,
'required' => false,
])
->add('genus', EntityType::class, [
'placeholder' => 'All',
'class' => TemplateGenus::class,
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('tg')
->andWhere('tg.id IN(1,4)')
->orderBy('tg.name', 'ASC');
},
'required' => false,
'choice_label' => 'name',
])
->add('category', EntityType::class, [
'multiple' => true,
'expanded' => true,
'required' => false,
'class' => TemplateCategory::class,
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('tc')
->andWhere('tc.id IN(1,2,3,4,5,6,7)')
->orderBy('tc.id', 'ASC');
},
'choice_label' => 'name',
// 'choices' => [
// 'Rod' => 'category_rod',
// 'Lure' => 'category_lure',
// 'Hat' => 'category_hat',
// 'Chest' => 'category_chest',
// 'Tacklebox' => 'category_tacklebox',
// 'Boots' => 'category_boots',
// 'Charm' => 'category_charm',
// ],
])
// ->add('status', ChoiceType::class, [
// 'required' => false,
// 'placeholder' => 'Status...',
// 'choices' => [
// 'Active' => 'status_active',
// 'Sold' => 'status_sold',
// ],
// ])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
// Configure your form options here
]);
}
}