nbonniot
nbonniot

Reputation: 1126

EasyAdmin : custom type for a field

I would like to use a custom Type of mine for a field in an EA managed entity.

I'm using SF Flex so my type is autowired and setup as service correctly (appears with debug:container).

Now, I would expect to do something like below in easy_admin.yaml :

    Menu:
        class: Lch\MenuBundle\Entity\Menu
        help: 'admin.site.menu.help'
        controller: App\Controller\Admin\Site\MenuController
        list:
            fields:
                - title
                - location
        form:
            fields:
                - title
                - location
                - { property: menuItems, type: 'lch_menu_tree' }

I found in documentation that you can't put anything in here but native Type or EA ones.

How can I setup EA to make it use my type for this particular field?

Upvotes: 2

Views: 6351

Answers (1)

yceruto
yceruto

Reputation: 9575

Use its fully qualified class name as expected for custom form type, e.g:

- { property: menuItems, type: 'App\Form\Type\LchMenuTree' }

You can use the short type name while it's a known type for EasyAdmin. The list of mapped types is here. Otherwise, you must to provide its FQCN as required by the Form component.

Upvotes: 7

Related Questions