I am trying to create new content using Sonata Admin, however due the entity is an abstract class
I am getting on screen a new panel with title Select object type
and the content has a blue box that says No object types available
.
I don't know what kind of settings I need to set-up in order to be able to select and create one of the entities that are extending my abstract class
.
Any help will be more than welcomed!
AppBundle\\Entity\\AbstractAlert
/**
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(
* name="dtype",
* type="string"
* )
* @ORM\DiscriminatorMap({
* "email" = "AppBundle\Entity\EmailAlert",
* "sms" = "AppBundle\Entity\SmsAlert"
* })
*/
abstract class AbstractAlert
{
}
AppBundle\\Entity\\EmailAlert
class EmailAlert extends AbstractAlert
{
}
AppBundle\\Entity\\SmsAlert
class SmsAlert extends AbstractAlert
{
}
SonataAdminBundle\\Admin\\AlertAdmin
class MassiveAlertAdmin extends AbstractAdmin
{
protected function configureFormFields(FormMapper $form)
{
$form
->with('panel name')
->add('fieldName')
->end();
}
}
This is how it looks my Sonata Admin => Create page
If any of you can give me a clue please, I will appreciate it.
Thanks in advance for your help,
Ok, i was wrong and finally found a solution for you ... you have only to choose the abstract entity as you already got and set subclasses via DI as shown here in 16.3 https://sonata-project.org/bundles/admin/2-1/doc/reference/advance.html ... that works like a charm and you'll get your choices in the add button! If not, i could imagine, that every concrete entity class also must have a own admin services, my classes already does. And for me: learning never stops ... Sorry for my wrong answer in the previous post ... having this knowledge helps me also now, improving my code. Thanks for that.
From 11/2018, i have the same problem but i use yaml to the config of the services.
The class 'Operation' is the abstract one.
Here is a example with yaml
app.admin.operation:
class: App\Admin\OperationAdmin
arguments: [~, App\Entity\Operation, ~]
tags:
- { name: sonata.admin, manager_type: orm, group: "app.admin.group.operation", label: Operation }
calls:
- [ setSubClasses, [{ TeamOperation: App\Entity\TeamOperation, Staff: App\Entity\StaffOperation, PlayersOperation: App\Entity\PlayersOperation} ]]
Whit this type of configuration you can select the type of 'Operation' between that 3 entities.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.