I have an entity City with more than 30000 objects stored. User is able to add an Address object with a relation ManyToOne to City.
But during Form building, the rendering of <input> type radio or select is not appropriate for the number of objects...
I use the following implementation code (it is a snippet):
public function buildForm(FormBuilderInterface $builder, array $options)
{
/* Pattern to get cities */
$pattern = 'Bor%'; //I use this filter to reduce the number of objects but not sufficient
$builder
->add('city', EntityType::class, array(
'class' => 'AppPlatformBundle:City',
'choice_label' => 'name',
'multiple' => false,
'expanded' => true,
'query_builder'=> function(CityRepository $repository) use($pattern) {
return $repository->getCitiesWithPattern($pattern);
}));
}
I think that a solution is to use a TextType where the proposals can be selected by the user when he start type anything. But I haven't idea on how implement this.
Do you have a solution on my issue please?
Thank you