Answer the question
In order to leave comments, you need to log in
How to make 2 entity editing pages with different forms in SonataAdminBundle?
Good afternoon.
How to make 2 entity editing pages with different forms in SonataAdminBundle?
For example, on one page, all fields of the User entity are edited (full editing), and on the other, only some (short editing).
Is there any way to set the context?
Answer the question
In order to leave comments, you need to log in
You can resolve the content at the request level with an additional parameter (a-la editing_context=simple) and configureFormFields
get it from the request in the method
$this->getRequest()->get('editing_context', $fallbackContext)
ifTrue, ifFalse
and you can write beautiful code without any snot like:$formMapper
->add('name')
->ifTrue($editingContext === 'full')
->add('someField1')
->add('someField2')
->ifEnd()
->add('createdAt')
;
Just create two different admin entities associated with the same entity.
For example, this is how it is done in my bundle in the config , and here the entries are shown by condition .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question