Closed core23 closed 2 years ago
Inject admin to Block will not be working?
IMO we should move all SonataFormType to form-extensions. I know this will be very hard things to do. Some of it require Admin but should be change for something new like CRUDInterface which will be part of admin on the feature. This will allow use sonata awesome form without admin(people will be able to easy configure own CRUD for ModelType). For me it should be milestone 5.
Inject admin to Block will not be working?
That's the current solution for most blocks (e.g. https://github.com/sonata-project/SonataMediaBundle/blob/3.x/src/Block/MediaBlockService.php#L144), but it looks hacky. This will add a hard admin dependency to the block, also if you want to use the block for the non-admin user in the frontend.
IMO we should move all SonataFormType to form-extensions. I know this will be very hard things to do. Some of it require Admin but should be change for something new like CRUDInterface which will be part of admin on the feature.
This will not solve the problem, because you only use the block inside the admin context, not the frontend user context.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
There is a problem if you use custom blocks that rely on an entity. You have to use the ModelListType and define a field description and some other technical stuff.
I don't fully understand the issue since I personally already use the EntityType in the admin.
$form
->add('contactReason', EntityType::class, [
'class' => ContactReason::class,
'choice_label' => function (ContactReason $contactReason): ?string {
return $contactReason->getReason();
},
'group_by' => function (ContactReason $contactReason): ?string {
$reasonFamily = $contactReason->getReasonFamily();
return null !== $reasonFamily ? $this->getTranslator()->trans($reasonFamily) : null;
},
'expanded' => false,
'required' => false,
]);
Where are you force to use those types ?
I don't fully understand the issue since I personally already use the EntityType in the admin.
Yes, you can use the EntityType
for a block, but you can't create a new entity or use advanced filtering, when displaying the this block in an admin form (e.g. using the PageBundle).
I'd like to have the ModelListType
functionality for an EditableBlockService
without coupling the block to the admin bundle.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Feature Request
This is just an idea I had when looking at an old issue that is still present.
There is a problem if you use custom blocks that rely on an entity. You have to use the
ModelListType
and define a field description and some other technical stuff. This is kind of okay, if you want to use the block editing function only inside the sonata page admin. But if you want to edit the same block in some non-sonata page (e.g. user frontend page), you can't reuse the block.To resolve this problem, we could use the
EntityType
which is a symfony standard component that renders a list of all entity values. We could then define someFormTypeExtension
that adds all functionality to this type (if you are inside admin context).Here's an example code if you want to use the
EntityType
inside an admin class.And an other example for a block. Depending on where you render this block edit form, you should see a normal entity type list or an entity type picker (if you are inside an admin).