0

I've a custom route and form, form input field(s) slightly changes based on arguments passed to it. There are only 2 possible arguments can be passed in URL. I'm using current latest version of Drupal 8 i.e. 8.6.14.

Following is copy of route from module:

mymodule.form:
  path: '/mymodule/{url_option}'
  defaults:
    _form: '\Drupal\mymodule\Form\ModuleForm'
    url_option: 'custom'
  requirements:
    _permission: 'access content'
    url_option: '^[a-zA-Z]*'

The above was working with earlier version of Drupal (It stopped working recently after updating to 8.6.x).

Issue : When I try to add a menu item (using "Admin => Structure => Menu") for this route, I get following error. I've tried both "/mymodule" and "/mymodule/custom".

The website encountered an unexpected error. Please try again later.Drupal\Core\Entity\EntityStorageException: The "url_option" entity type does not exist.

I've also tried implementing ParamConverter, but that didn't worked either. And since there are only 2 possible arguments user can pass, I'm not creating it an entity.

EDIT : Updated Issue.

  • It's a long shot but the regex looks a little on the weak side. That's potentially going to match '/mymodule', '/mymodule/foo', '/mymodule/bar' and so on, which might be messing with the default value. Try replacing * with +, rebuilding cache and try again – Clive Apr 15 at 8:44
  • @Clive, small correction in question, I've updated question with same. URL shows page not found when I return NULL from ParamConverter's "convert" method. In case of normal route, URL shows form, but "Add menu item" doesn't work. – Yogesh Apr 15 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.