Skip to content

[Form] query_builder will only get used for the first document Field Type #4894

@mrohnstock

Description

@mrohnstock

(don't know, if this is only DoctrineMongoDBBundle-related)
I've a Document like this:

/**
 * @ODM\Document(collection="group")
 */
class Group
{
    /**
     * @ODM\String
     */
    protected $type;

    /**
     * @param String
     */
    public function setType($type)
    {
        $this->type = $type;
    }

    /** 
     * @return String
     */
    public function getType()
    {
        return $this->type;
    }
}

And will add a Form, with two document Field Types, where field1:
type=='Terminal'
and field2:
type=='Location'

So my Form looks like this:

$builder->add('terminalGroup', 'document', array('required' => false, 'class' => 'test\TestBundle\Document\Group',    'query_builder' => function(DocumentRepository $dm) { return $dm->createQueryBuilder('')->field('type')->equals('Terminal');}));
$builder->add('locationGroup', 'document', array('required' => false, 'class' => 'test\TestBundle\Document\Group',    'query_builder' => function(DocumentRepository $dm) { return $dm->createQueryBuilder('')->field('type')->equals('Location');}));

Form-Field terminalGroup and locationGroup display the same Documents (any document, which holds type = 'Terminal').

I recognized the issue first today, don't know if this is related on PR #4881

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions