Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
893 views
in Technique[技术] by (71.8m points)

symfony4 - Symfony + Sonata Admin - unmapped ModelAutocompleteType?

Symfony 4.4, Doctrine 2.7, Sonata Admin 3.7

I am trying to achieve single table inheritance (or something similar) support in Sonata. I have an entity Article which should have many RecommendedContent entities. Now, RecommendedContent can have multiple types, let's say News, BlogPost etc.

So RecommendedContent will hade id, article_id, type and content_id.

My question is about RecommendedContentAdmin form. What works is setting type field as ChoiceFieldMaskType and displaying one of unmapped EntityType fields (for News or BlogPost).

The problem is that there can a huge amount of News or Blogposts, that makes the whole RecommendedContentAdmin load too long and if I will use it inside ArticleAdmin as CollectionType field, this will be a nightmare.
So I want user to be able to choose content using ModelAutocompleteType, which... does not seem to support 'mapped'=>false in formbuilder.
Is there any other possibility to add not mapped field, which will be a simple ajax autocomplete field for existing entity?

Note: I don't really need separate entities (typical Doctrine single table inheritance) for every content type, if not needed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...