If you create a webform with more than one wizard page (multipage form) and you use an Entity autocomplete (with 'Tags' checked) on a page, which is not the last page, you will get a white screen after submitting the page with the following message "The website encountered an unexpected error. Please try again later".
If you have a look inside the 'Recent log messages' there is a PHP-Error with the following message:
"InvalidArgumentException: The #default_value property has to be an entity object or an array of entity objects. in Drupal\Core\Entity\Element\EntityAutocomplete::valueCallback() (line 68 of /home/drg5p/www/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php)."
Also the "Test" functionality of the webform is broken and produces the same error.
How to reproduce:
- Create a wizard page
- Add a Entity autocomplete field inside this page. Make sure to activate the "Tags" checkbox. Choose 'Taxonomy Term' under Type of item to reference and check the Create referenced entities if they don't already exist. As Vocabulary check 'Tags'
- Save this field
- Create another wizard page
- Just add a simple text field inside of it.
- Now view the form on your website
- Add 'test1, test2, test3' as value inside the Entity autocomplete field.
- Click on 'Next page'
- Now the error is occuring
If you put the Entity autocomplete on the last page of the wizard, everything is working fine. But not on the pages before, as I mentioned above.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 3068778-11.patch | 13.06 KB | jrockowitz |
| #9 | 3068778-9.patch | 1.49 KB | jrockowitz |
| #7 | 3068778-7.patch | 637 bytes | jrockowitz |
| #2 | webform.webform.issue_3068778.yml | 4.72 KB | jrockowitz |
| #3 | webform.webform.issue_3068778.yml | 4.76 KB | alxshell |
Comments
Comment #2
jrockowitz commentedI am not able to replicate this issue using the attached webform.
Can you please provide an example webform which can be used to replicate this issue?
Comment #3
alxshell commentedHi Jacob,
thank you for your quick reply. I added two lines to your autocomplete field config inside the .yml-file which appeared additionally, after I changed the corresponding options.
Now the error is reproducable.
Comment #4
jrockowitz commentedYes, I can reproduce this issue using the below YAML source
Comment #5
alxshell commentedThank you for the confirmation. Glad that you could reproduce it. So do you need more information or can we change the status?
Comment #6
jrockowitz commentedComment #7
jrockowitz commentedWow!!! I think the solution might be a one-line fix. @Sentry Can you please review the attached patch.
Comment #9
jrockowitz commentedI think the Entity Automcomplete element may need some dedicated test coverage.
Comment #10
jrockowitz commentedComment #11
jrockowitz commentedSo the
'#multiple'and'#tags'can't be used together. These two properties can only be added via the source mode. The attached patch prevents the fatal error and moves the entity autocomplete element to a dedicated test.Comment #13
jrockowitz commentedI committed the patch. Please download the latest dev release to review.