Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoFormType doesn't support Embedded properties #17

Open
welcoMattic opened this issue Oct 9, 2019 · 1 comment
Open

AutoFormType doesn't support Embedded properties #17

welcoMattic opened this issue Oct 9, 2019 · 1 comment

Comments

@welcoMattic
Copy link

Hi, thanks a lot for this bundle and TranslationFormBundle, it helps me in many projects !

So, I have a little bit complex context. I work with EasyAdminBundle:

I have a VideoBlock class, translatable (and a VideoBlockTranslation class). In VideoBlock class I have a $videoMedia property, which is declared as follow:

/**
 * @ORM\Embedded(class="App\Entity\CatalogMedia")
 */
private $videoMedia;

CatalogMedia extract:

/**
 * @ORM\Embeddable()
 */
class CatalogMedia
{
    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $filename;

    private $file;

// ...

It works like a charm, but now I would like to be able to upload a video for each language. Basically, move $videoMedia in VideoBlockTranslation. Well, here is the problem. If I do this, I can't make my form works. The form is configured like this:

// ... EasyAdmin entity config
            form:
                fields:
                    - { type: 'group', css_class: 'col-md-6', icon: 'gear', label: 'Configuration' }
                    - { property: 'name', label: 'Nom' }

                    - { type: 'group', css_class: 'col-md-6', icon: 'image', label: 'Media' }
                    - { property: 'videoMedia', label: 'Vidéo', type: 'App\Form\CatalogMediaType' }

                    - { type: 'group', css_class: 'col-md-12', icon: 'flag', label: 'Traductions' }
                    - property: 'translations'
                      type: 'A2lix\TranslationFormBundle\Form\Type\TranslationsType'
                      type_options:
                          label: false
                          fields:
                              title: { label: 'titre' }
                              content: { label: 'paragraphe' }

If I move videoMedia, under translations...fields, Symfony tells me that it can't find videoMedia property in VideoBlockTranslation class 🤔

May be I missed something, but I think that the problem is under AutoFormBundle and about Embedded properties.

Thanks for helping

@StephenBeirlaen
Copy link

I have the same issue. The field validation logic uses the list of fields that Doctrine has mapped. Any extra fields will be marked as invalid.
Might look at this later, for now I have little time to look further into this, I can stay at version 2 for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants