I have a multistep webform on my D8 Website. When I click "next" on the first page, I get the notice which I paste below:

Notice: Uninitialized string offset: 0 in Drupal\Core\Render\Element::property() (line 27 of /var/www/html/core/lib/Drupal/Core/Render/Element.php) 

#0 /var/www/html/core/includes/bootstrap.inc(566): _drupal_error_handler_real(8, 'Uninitialized s...', '/var/www/html/t...', 27, Array) 

#1 /var/www/html/core/lib/Drupal/Core/Render/Element.php(27): _drupal_error_handler(8, 'Uninitialized s...', '/var/www/html/t...', 27, Array) 

#2 /var/www/html/modules/webform/src/WebformSubmissionConditionsValidator.php(347): Drupal\Core\Render\Element::property('') 

#3 /var/www/html/modules/webform/src/WebformSubmissionConditionsValidator.php(333): Drupal\webform\WebformSubmissionConditionsValidator->getVisibleElementsRecusive(Array, Array) 

#4 /var/www/html/modules/webform/src/WebformSubmissionConditionsValidator.php(144): Drupal\webform\WebformSubmissionConditionsValidator->getVisibleElements(Array) 

#5 /var/www/html/modules/webform/src/WebformSubmissionForm.php(1085): Drupal\webform\WebformSubmissionConditionsValidator->validateForm(Array, Object(Drupal\Core\Form\FormState)) 

#6 [internal function]: Drupal\webform\WebformSubmissionForm->validateForm(Array, Object(Drupal\Core\Form\FormState)) 

#7 /var/www/html/core/lib/Drupal/Core/Form/FormValidator.php(83): call_user_func_array(Array, Array) 

#8 /var/www/html/core/lib/Drupal/Core/Form/FormValidator.php(270): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState)) 

#9 /var/www/html/core/lib/Drupal/Core/Form/FormValidator.php(119): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'webform_submiss...') 

#10 /var/www/html/core/lib/Drupal/Core/Form/FormBuilder.php(571): Drupal\Core\Form\FormValidator->validateForm('webform_submiss...', Array, Object(Drupal\Core\Form\FormState)) 

#11 /var/www/html/core/lib/Drupal/Core/Form/FormBuilder.php(314): Drupal\Core\Form\FormBuilder->processForm('webform_submiss...', Array, Object(Drupal\Core\Form\FormState)) 

#12 /var/www/html/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm('webform_submiss...', Object(Drupal\Core\Form\FormState)) 

#13 /var/www/html/modules/webform/src/Entity/Webform.php(986): Drupal\Core\Entity\EntityFormBuilder->getForm(Object(Drupal\webform\Entity\WebformSubmission), 'add') 

#14 /var/www/html/modules/webform/src/Controller/WebformController.php(83): Drupal\webform\Entity\Webform->getSubmissionForm() 

#15 [internal function]: Drupal\webform\Controller\WebformController->addForm(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\webform\Entity\Webform)) 

#16 /var/www/html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) 

#17 /var/www/html/core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() 

#18 /var/www/html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) 

#19 /var/www/html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) 

#20 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() 

#21 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(144): call_user_func_array(Object(Closure), Array) 

#22 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(64): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) 

#23 /var/www/html/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 

#24 /var/www/html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 

#25 /var/www/html/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 

#26 /var/www/html/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) 

#27 /var/www/html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 

#28 /var/www/html/modules/devel/webprofiler/src/StackMiddleware/WebprofilerMiddleware.php(38): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 

#29 /var/www/html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 

#30 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 

#31 /var/www/html/core/lib/Drupal/Core/DrupalKernel.php(656): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 

#32 /var/www/html/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) 

#33 {main}. 

Comments

Orkut Murat Yılmaz created an issue. See original summary.

jrockowitz’s picture

Status: Active » Postponed (maintainer needs more info)

I can't reproduce this error using the Example: Wizard (/form/example-wizard).

Please isolate the problem using basic webform, export it, and upload it here.

orkutmuratyilmaz’s picture

I've created a new multi page webform and I got the notice when I clicked on "next page" again. The export of my new webform is below:

uuid: 7f20da23-5c86-4b8d-afe7-89b51f6fcb95
langcode: en
status: open
dependencies: {  }
open: null
close: null
uid: 3
template: false
id: basic_multipage_webform
title: 'basic multipage webform'
description: ''
category: ''
elements: |
  page_1:
    '#type': webform_wizard_page
    '#title': 'page 1'
    message_1:
      '#type': webform_message
      '#message_message': 'message content'
  page_2:
    '#type': webform_wizard_page
    '#title': 'page 2'
    select_1:
      '#type': select
      '#title': select_1
      '#options': days
css: ''
javascript: ''
settings:
  ajax: false
  page: true
  page_submit_path: ''
  page_confirm_path: ''
  form_submit_once: false
  form_exception_message: ''
  form_open_message: ''
  form_close_message: ''
  form_previous_submissions: true
  form_confidential: false
  form_confidential_message: ''
  form_convert_anonymous: false
  form_prepopulate: false
  form_prepopulate_source_entity: false
  form_prepopulate_source_entity_required: false
  form_prepopulate_source_entity_type: ''
  form_reset: false
  form_disable_autocomplete: false
  form_novalidate: false
  form_unsaved: false
  form_disable_back: false
  form_autofocus: false
  form_details_toggle: false
  submission_label: ''
  submission_log: false
  submission_user_columns: {  }
  wizard_progress_bar: true
  wizard_progress_pages: false
  wizard_progress_percentage: false
  wizard_start_label: ''
  wizard_complete: true
  wizard_complete_label: ''
  preview: 0
  preview_label: ''
  preview_title: ''
  preview_message: ''
  preview_attributes: {  }
  preview_excluded_elements: {  }
  preview_exclude_empty: true
  draft: none
  draft_multiple: false
  draft_auto_save: false
  draft_saved_message: ''
  draft_loaded_message: ''
  confirmation_type: page
  confirmation_title: ''
  confirmation_message: ''
  confirmation_url: ''
  confirmation_attributes: {  }
  confirmation_back: true
  confirmation_back_label: ''
  confirmation_back_attributes: {  }
  limit_total: null
  limit_total_message: ''
  limit_user: null
  limit_user_message: ''
  purge: none
  purge_days: null
  entity_limit_total: null
  entity_limit_user: null
  results_disabled: false
  results_disabled_ignore: false
  token_update: false
access:
  create:
    roles:
      - anonymous
      - authenticated
    users: {  }
    permissions: {  }
  view_any:
    roles: {  }
    users: {  }
    permissions: {  }
  update_any:
    roles: {  }
    users: {  }
    permissions: {  }
  delete_any:
    roles: {  }
    users: {  }
    permissions: {  }
  purge_any:
    roles: {  }
    users: {  }
    permissions: {  }
  view_own:
    roles: {  }
    users: {  }
    permissions: {  }
  update_own:
    roles: {  }
    users: {  }
    permissions: {  }
  delete_own:
    roles: {  }
    users: {  }
    permissions: {  }
handlers: {  }
jrockowitz’s picture

Thanks for the example. I can't reproduce the issue locally using the Bartik theme.

The Notice: Uninitialized string offset: 0 usually indicates there is empty property on a element.

  select_1:
      '#type': select
      '#title': select_1
      '#options': days
      # Below property would throw an error.
      'error': ''

Are you able to replicate the issue via clean install on https://simplytest.me/?

orkutmuratyilmaz’s picture

I switched back to 8.x-5.0-beta16 and the notice is disappeared now.

jrockowitz’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
orkutmuratyilmaz’s picture

This notice came back, when I updated to 8.x-5.0-beta18. So I downgraded back to 8.x-5.0-beta16.

I'm still looking for a solution, because I'd like to keep my web app updated.

orkutmuratyilmaz’s picture

Status: Closed (cannot reproduce) » Active
jrockowitz’s picture

@Orkut Murat Yılmaz.

Are you able to reproduce the error using https://simplytest.me?

Are you using any modules or themes that could be altering your webforms? Try disabling these modules

jrockowitz’s picture

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

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Closing because no one has responded with more information.

bogdan.racz’s picture

StatusFileSize
new648 bytes

I have the same problem.
I wasn't able to find the real issue, but I noticed that somehow in the WebformSubmissionConditionsValidator class, in the validateFormRecursive method, one of the keys in the form array is empty, so the Element::property($key) triggers the notice.
I added an extra empty check for the key, see the patch bellow.

bogdan.racz’s picture

Status: Closed (cannot reproduce) » Needs review

Status: Needs review » Needs work

The last submitted patch, 12: notice_uninitialized-2905907-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

bogdan.racz’s picture

Assigned: Unassigned » bogdan.racz
Status: Needs work » Active
jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new631 bytes

The failing test most likely has to do with empty($key) is seeing a '0' array index as empty.

I am not sure the attached patch will work.

  • jrockowitz committed 5cb7129 on 8.x-5.x
    Issue #2905907 by jrockowitz, rbmboogie: Notice: Uninitialized string...
jrockowitz’s picture

Status: Needs review » Fixed

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

Status: Fixed » Closed (fixed)

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