Skip to content

Doctrine Collection support #49

@secit-pl

Description

@secit-pl

I found that the bundle have problems when dealing with Doctrine\Common\Collections\Collection (ArrayCollection). On local test instance I have found that the problem is here:

Matthias\SymfonyConsoleForm\Bridge\Transformer\AbstractTransformer::defaultValueFrom

    protected function defaultValueFrom(FormInterface $form)
    {
        $defaultValue = $form->getData();
        if (is_array($defaultValue)) {
            $defaultValue = implode(',', $defaultValue);
        }

        return $defaultValue;
    }

after changing it to:

    protected function defaultValueFrom(FormInterface $form)
    {
        $defaultValue = $form->getData();
        if (is_array($defaultValue)) {
            $defaultValue = implode(',', $defaultValue);
        } elseif ($defaultValue instanceof Collection) {
            $defaultValue = implode(',', $defaultValue->toArray());
        }

        return $defaultValue;
    }

the Collection is handled properly and even form type Symfony\Bridge\Doctrine\Form\Type\EntityType is working very well.

Could you please look at this and apply the patch if the solution is valid?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions