Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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}).
Comment | File | Size | Author |
---|---|---|---|
#4 | drupal8.routing-system.2090581-4.patch | 3.35 KB | disasm |
#4 | interdiff.txt | 895 bytes | disasm |
#2 | drupal-custom-form-controllers-named-parameters-upcasting-2090581-1.patch | 3.34 KB | juampynr |
#1 | drupal-custom-form-controllers-named-parameters-upcasting-2090581-1.patch | 0 bytes | juampynr |
Comments
Comment #1
juampynr CreditAttribution: juampynr commentedHere is a test that proves it.
Comment #2
juampynr CreditAttribution: juampynr commentedDoh! Empty patch. Thanks @timplunkett for checking.
Comment #4
disasm CreditAttribution: disasm commentedIf 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.
Comment #5
juampynr CreditAttribution: juampynr commentedGotcha! Thanks for the explanation.
Closing.