Question : Extend Base FormFilterType
Hi, This is my first time use this Bundle and English not my native language so I'm sorry for my mistakes.

I create my own FilterType and extend Basic filter type of this bundle ... When I use my filtertype in FormFilterType, form type not work and querybuilder not change ... But when use basic formfiltertype instead of my filtertype everything is fine ... Where is my mistake?
Update: Why I need to override types?
I have several entity and all of them has Id , TrackingNumber ... I need to define label or other options in one place and use that in all of entityFilters ...
class RequestFilterType extends AbstractType
{
/**
* {@inheritdoc}
*
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder
->add('trackingNumber', TrackingNumberFilterType::class)
}
/**
* {@inheritdoc}
*
* @return null|string
*/
public function getParent()
{
return FormFilterType::class;
}
/**
* {@inheritdoc}
*
* @return null|string
*/
public function getBlockPrefix()
{
return 'assessment_request_filter';
}
}
___________________________
class TrackingNumberFilterType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder
->add('trackingNumber', NumberFilterType::class, array(
'label' => false,
'attr' => array(
'placeholder' => 'narmafzam.fields.trackingNumber'
)
));
}
/**
* {@inheritdoc}
*
* @return null|string
*/
public function getBlockPrefix()
{
return 'narmafzam_tracking_number_filter';
}
}
Perhaps something like the following would work for you, since it looks like you just want to populate some default values to some existing options.
// src/AppBundle/Form/TrackingNumberFilterType.php
namespace AppBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\NumberFilterType;
class TrackingNumberFilterType extends AbstractType
{
/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'label' => false,
'placeholder' => 'narmafzam.fields.trackingNumber',
]);
}
/**
* @return string
*/
public function getParent()
{
return NumberFilterType::class;
}
}
// src/AppBundle/Form/RequestFilterType.php
namespace AppBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class RequestFilterType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('trackingNumber', TrackingNumberFilterType::class)
}
}
Up?