Skip to content

Many to Many choice list bug #9550

@i-void

Description

@i-void

I debug myself a bug which you can reproduce by using propel1's model form field type in a form. I used the field type for many to many relation to render a multi selectable checkgroup;

                $builder->add('products', 'model', array(
                    'class' => 'Acme\XXBundle\Model\Product',
                    'property' => 'name',
                    'label' => ' ',
                    'expanded' => true,
                    'multiple' => true,
                    'attr' => ['class'=>'css-checkbox'],
                ));

this is for Company->Follows<-Products (Many company can follow many product)
but when rendered the form followed products didn't come ticked for the company. I debug and the problem is on vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php in the getValuesForChoices function. In this function
if ($choice === $givenChoice) { will not work for classes. You must change this to if ($choice == $givenChoice) {. I tested and now it can tick the choices which are on the follow table.

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