简体   繁体   中英

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?

Use its fully qualified class name as expected for custom form type, eg:

- { 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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM