Problem/Motivation
Since I updated the module to 6.1.0, I'm getting PHP warnings in the log when someone submits a contact form with empty Message.
Steps to reproduce:
- install with standard profile
- enable webform, disable_html5_validation, captcha modules
- /admin/structure/webform/manage/contact, set the "Elements (YAML)" to this:
container:
'#type': container
'#attributes':
class:
- form-border
name:
'#title': 'Your Name'
'#type': textfield
'#required': true
'#default_value': '[current-user:display-name]'
phone:
'#type': textfield
'#title': Phone
email:
'#title': 'Your Email'
'#type': email
'#required': true
'#default_value': '[current-user:mail]'
message:
'#title': Message
'#type': textarea
'#required': true
'#test': 'Please ignore this email.'
captcha:
'#type': captcha
actions:
'#type': webform_actions
'#title': 'Submit button(s)'
'#submit__label': 'Send message'
'#submit__attributes':
class:
- cta
- /admin/config/people/captcha tick "Add CAPTCHA administration links to forms"
- visit /webform/contact as admin and click to "Send message" with empty message.
- the PHP warning should be logged in /admin/reports/dblog
Error messages:
Notice: Undefined index: #parents in Drupal\Core\Form\FormState->getError() (line 1112 of core/lib/Drupal/Core/Form/FormState.php).
Drupal\Core\Form\FormState->getError(Array) (Line: 164)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object, Array) (Line: 124)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object, Array) (Line: 124)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object) (Line: 26)
Drupal\Core\Form\FormErrorHandler->handleFormErrors(Array, Object) (Line: 199)
Drupal\Core\Form\FormValidator->finalizeValidation(Array, Object, 'webform_submission_contact_add_form') (Line: 119)
Drupal\Core\Form\FormValidator->validateForm('webform_submission_contact_add_form', Array, Object) (Line: 589)
Drupal\Core\Form\FormBuilder->processForm('webform_submission_contact_add_form', Array, Object) (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'add') (Line: 1233)
Drupal\webform\Entity\Webform->getSubmissionForm() (Line: 76)
Drupal\webform\Controller\WebformEntityController->addForm(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 578)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 717)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Warning: Invalid argument supplied for foreach() in Drupal\Core\Form\FormState->getError() (line 1112 of core/lib/Drupal/Core/Form/FormState.php).
Drupal\Core\Form\FormState->getError(Array) (Line: 164)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object, Array) (Line: 124)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object, Array) (Line: 124)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object) (Line: 26)
Drupal\Core\Form\FormErrorHandler->handleFormErrors(Array, Object) (Line: 199)
Drupal\Core\Form\FormValidator->finalizeValidation(Array, Object, 'webform_submission_contact_add_form') (Line: 119)
Drupal\Core\Form\FormValidator->validateForm('webform_submission_contact_add_form', Array, Object) (Line: 589)
Drupal\Core\Form\FormBuilder->processForm('webform_submission_contact_add_form', Array, Object) (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'add') (Line: 1233)
Drupal\webform\Entity\Webform->getSubmissionForm() (Line: 76)
Drupal\webform\Controller\WebformEntityController->addForm(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 578)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 717)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
jrockowitz commentedI am not able to replicate this issue using the attached webform.
Are you able to replicate this issue using https://simplytest.me?
Comment #3
kaszarobertI added steps to reproduce as this only happens when you use webform with captcha and disable_html5_validation modules & you set to display the "Untrusted users will see a CAPTCHA element on this webform." message or link on the webform.
Comment #4
kaszarobertComment #5
kaszarobertComment #6
kaszarobertComment #8
jrockowitz commentedComment #9
jrockowitz commented