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:

  1. Create a wizard page
  2. 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'
  3. Save this field
  4. Create another wizard page
  5. Just add a simple text field inside of it.
  6. Now view the form on your website
  7. Add 'test1, test2, test3' as value inside the Entity autocomplete field.
  8. Click on 'Next page'
  9. 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.

Comments

Sentry created an issue. See original summary.

jrockowitz’s picture

Priority: Critical » Major
Status: Active » Postponed (maintainer needs more info)
StatusFileSize
new4.72 KB

I 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?

alxshell’s picture

StatusFileSize
new4.76 KB

Hi 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.

'#multiple': 0
'#tags': true

Now the error is reproducable.

jrockowitz’s picture

Yes, I can reproduce this issue using the below YAML source

page_1:
  '#type': webform_wizard_page
  '#title': page_1
  entity_autocomplete:
    '#type': entity_autocomplete
    '#title': entity_autocomplete
    '#multiple': 0
    '#tags': true
    '#target_type': taxonomy_term
    '#selection_handler': 'default:taxonomy_term'
    '#selection_settings':
      target_bundles:
        tags: tags
      sort:
        field: name
        direction: ASC
      auto_create: true
      auto_create_bundle: tags
page_2:
  '#type': webform_wizard_page
  '#title': page_2
  textfield:
    '#type': textfield
    '#title': textfield
alxshell’s picture

Thank you for the confirmation. Glad that you could reproduce it. So do you need more information or can we change the status?

jrockowitz’s picture

Status: Postponed (maintainer needs more info) » Needs work
jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new637 bytes

Wow!!! I think the solution might be a one-line fix. @Sentry Can you please review the attached patch.

Status: Needs review » Needs work

The last submitted patch, 7: 3068778-7.patch, failed testing. View results

jrockowitz’s picture

StatusFileSize
new1.49 KB

I think the Entity Automcomplete element may need some dedicated test coverage.

jrockowitz’s picture

Status: Needs work » Needs review
jrockowitz’s picture

StatusFileSize
new13.06 KB

So 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.

  • jrockowitz authored ddbdefc on 8.x-5.x
    Issue #3068778 by jrockowitz, Sentry: Site is not being rendered when...
jrockowitz’s picture

Status: Needs review » Fixed

I committed the patch. Please download the latest dev release to review.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.