Problem/Motivation
At saving an entity using a vat_number field, this warning is raised:
Warning : Undefined array key "#webform_key" dans Drupal\vat_number\Element\VatNumber::validateVatNumber() (/var/www/html/web/modules/contrib/vat_number/src/Element/VatNumber.php ligne 37)
followed by this error:
TypeError: Drupal\Component\Utility\NestedArray::setValue(): Argument #1 ($array) must be of type array, string given, called in /var/www/html/web/core/lib/Drupal/Core/Form/FormStateValuesTrait.php on line 46 in Drupal\Component\Utility\NestedArray::setValue() (line 147 of /var/www/html/web/core/lib/Drupal/Component/Utility/NestedArray.php).
Steps to reproduce
Use an entity with vat_number field. Create an entity or save an existing entity with a vat number.
Proposed resolution
The fix is to replace the setValue() call with setValueForElement(), which is the correct API for element validators — it uses $element['#parents'] (always present) instead of the webform-specific #webform_key.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3589690-vat_number-undefined_webform_key.patch | 614 bytes | xdequinze |
Issue fork vat_number-3589690
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
xdequinzeComment #3
xdequinzeThis patch fixes my issue.
Comment #7
dieterholvoet commentedThanks!