8

I got 2 entities linked by a 'OneToMany' relationship. One of the entities is the object City. The table corresponding to this object includes almost 37000 entries. When I proceed to the creation of a form to populate the Proprietairy entity in Symfony, I use a FormType which looks like below. It includes a field corresponding to the City Object

namespace Immo\BienBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

class ProprietaireType extends AbstractType {
    public function buildForm(FormBuilder $builder, array $options) {
        $builder
        ->add('nom')
        ->add('prenom')
        ->add('email')
        ->add('telephone')
        ->add('adresse')
        ->add('city', 'entity', array(
            'class'=>'Immo\BienBundle\Entity\City', 
            'property'=>'city'));
    }

    public function getName() {
        return 'immo_bienbundle_proprietairetype';
    }
}

The form renders a combobox. populated by the 36000 cities and takes incredibly long to load. I have tried the option fetch="extra_lazy", but it is still not efficient enough. My idea was to create a form with an input field working with ajax and displaying the list of the cities after the user provides 2 letters. I would appreciate any help from the community to create the needed relationship with my Object when validating.

2 Answers 2

2

Use https://github.com/symfony/symfony/pull/1951 Soon in the v2.1 I hope...

Sign up to request clarification or add additional context in comments.

Comments

0

You can use my bundle https://github.com/shtumi/ShtumiUsefulBundle to get ajax autocomplete form type

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.