Sonata admin form AdminType for virtual field

26 views Asked by At

I try to show inline admin for virtual field.

here is code

        $workTimeLogAdmin = $this->getConfigurationPool()->getAdminByAdminCode('app.admin.worktime.log');


        $fieldDescription = new FieldDescription('dd');
        $fieldDescription->setAdmin($this);
        $fieldDescription->setAssociationAdmin($workTimeLogAdmin);
//        $fieldDescription->setParentAssociationMappings([...]);

        $workTimeLogAdmin->setParentFieldDescription($fieldDescription);


        $form->add('test', AdminType::class, [
            'mapped' => false,
            'label' => 'Related Entity',
            'sonata_admin' => $workTimeLogAdmin, 
        ]);

also i try

 $form->add('test', CollectionType::class, [
            'entry_type' => AdminType::class, 
            'entry_options' => [
                'label' => false,
                'sonata_field_description' => $this->createFieldDescription('test'), 
                'sonata_admin' => 'app.admin.worktime.log', 
     
            ],
            'allow_add' => true,
            'allow_delete' => true,
            'mapped' => false,
            'required' => false,
        ], [
            'edit' => 'inline',
            'inline' => 'table',
            'sortable' => 'position',
        ]);

same result

The current field `test` is not linked to an admin. Please create one for the target model: ``.

is possible to create fake relation or ignore it in some way ?

0

There are 0 answers