Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Form] Query builder is run for each entity within each instance of a form within a collection #8658

Closed
@kriswillis

Description

@kriswillis

When building a form that has a collection field that contains a form with entity fields using thequery_builder option, the query is run for each instance in the collection.

Example:

// Main formpublicfunctionbuildForm(FormBuilderInterface$builder,array$options){$builder    ->add('participants','collection',array('type'         =>newParticipantType(),'allow_add'    =>true,'allow_delete' =>true,'by_reference' =>false,    ));}// Form used in collection (ParticipantType)publicfunctionbuildForm(FormBuilderInterface$builder,array$options){$builder    ->add('user','entity',array('class' =>'MyUserBundle:User','query_builder' =>function(EntityRepository$er) {return$er->createQueryBuilder('u')                ->orderBy('u.surname','ASC');        },    ))    ->add('relationship','entity',array('class' =>'MyOtherBundle:Relationship','query_builder' =>function(EntityRepository$er) {return$er->createQueryBuilder('r')                ->orderBy('r.name','ASC');        },    ));}

Now, if I generate this form with an entity that has 30participants, the query builder is run for both theuser andrelationship entity fields 30 times, resulting in 60 queries. Surely each query only needs to be run once?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp