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.