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

Mixing form types for embedmany field type #1270

Closed
OndrejPiza opened this issue Nov 9, 2015 · 3 comments
Closed

Mixing form types for embedmany field type #1270

OndrejPiza opened this issue Nov 9, 2015 · 3 comments
Labels

Comments

@OndrejPiza
Copy link

Hi,

have you ever need to add different types of forms based on provided document type? I'm trying to achieve something like collection behavior with all allow add , allow delete functionality, but with my own form types, so I can't settle with generated ones.

Thank for any advice

@malarzm
Copy link
Member

malarzm commented Nov 9, 2015

but with my own form types, so I can't settle with generated ones.

what do you mean by this?

@OndrejPiza
Copy link
Author

I'm using KNP Labs ORM Behavior modified for ODM with a2Lix translations bundle. I also have some special types, based on document, which I use for better selecting images (Referenced document). So I need to be able to specifiy form type and pass it to the form builder. Which I can't if collection is made dynamically, like you can add or delete new ones, but symfony won't recognize my own types and use default ones,. So I need to be able to loop through the embedded documents and add dynamically these new forms from them. Which is OK, each document know which form it needs.

But I don't know if this is correct aproach. It just sound natural to being able to mix document types in single collection of embedded documents, so I thought there is some way how to mix form types as well.

@malarzm
Copy link
Member

malarzm commented Nov 9, 2015

I thought there is some way how to mix form types as well.

That is good question for Symfony 👶 Anyway we have done something like this (unfortunately can't share the exact solution), we ended up extending collection type and having subscribers on PRE_SUBMIT and PRE_SET_DATE that are aggressively changing built form based on underlying data (basing on discriminators)

@malarzm malarzm closed this as completed Jan 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants