Forms inheriting from FormBase with the following route definition won't get its parameters upcasted to entities:

paramconverter_test.custom_form_node:
  path: '/paramconverter_test/custom_form/{foo}'
  requirements:
    _access: 'TRUE'
  defaults:
    _form: '\Drupal\paramconverter_test\TestForm'
  options:
    parameters:
      foo:
        type: 'entity:node'

If we use entity names as parameters within the path (for example, {node}).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

juampynr’s picture

Status: Active » Needs review
FileSize
0 bytes

Here is a test that proves it.

juampynr’s picture

Doh! Empty patch. Thanks @timplunkett for checking.

Status: Needs review » Needs work
disasm’s picture

Category: bug » task
Status: Needs work » Needs review
FileSize
895 bytes
3.35 KB

If your parameter in route is named {foo} you need to use $foo as your param to the buildForm function. Also, $foo->title is a field, your looking for $foo->getTitle(). Attaching a patch to prove this is not a bug and an interdiff.

juampynr’s picture

Status: Needs review » Closed (works as designed)

Gotcha! Thanks for the explanation.

Closing.