I've got a custom content entity type, created for me by drush generate and I'm extending that using bundle classes. I've got a MyContentType class and a MyBundle class that extends it and provides some additional fields. I'm able create MyBundle entities just fine with drush php or in a kernel test, so I know all that works. Now I'm trying to create MyBundle entities in the UI.

The annotation for the MyContentType class provides the path to my form handler

"add" = "Drupal\my_content_type\Form\MyContentTypeForm"

and a link to the form to add a new entity

"add-form" = "/my_content_type/add/{my_content_type}".

But when I try going to /my_content_type/add/my_bundle, I get a Page not found.

Following what I see in node.routing.yml, I've got this in my_module.routing.yml

  path: '/my_content_type/add/{my_content_type}'
    _title: 'Add some content'
    _form: 'Drupal\my_content_type\Form\MyContentTypeForm'
    _permission: 'administer site configuration'
        type: entity:my_content_type

Once I've created and saved one of my entities using drush php, the edit page loads fine. So, what's the silly little thing I'm missing here?

  • This is a bit confusing, the same name for entity type and bundle. And don't use the node entity as example, this was probably the first Drupal 8 entity. Newer entities don't use a routing file, they use a route provider class.
    – 4uk4
    Commented Aug 22, 2022 at 19:35
  • That's what I was hoping, too, but it's not doing the trick * "route_provider" = { * "html" = "Drupal\Core\Entity\Routing\AdminHtmlRouteProvider", * }''' Commented Aug 22, 2022 at 20:31

1 Answer 1


I think you should be using _entity_form rather than _form. See: https://www.drupal.org/docs/drupal-apis/routing-system/structure-of-routes (search for _entity_form).

  • Drat, that looks like just the kind of silly thing I was wondering about, but changing _form: 'Drupal\my_content_type\Form\MyContentTypeForm' to _entity_form: my_content_type.add didn't do what I hoped it would. Commented Aug 22, 2022 at 19:08
  • Maybe it should be _entity_form: my_content_type.add_form
    – Jaypan
    Commented Aug 22, 2022 at 19:11
  • No luck yet. Time to dig in with xdebug. Commented Aug 25, 2022 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.