I am trying to set up sending an email to all the users of a specific role. I clicked on "Add email," selected the role, CC to current user email address, turned off most of the included values, [Advanced] additional settings for on Completed. Then I clicked Save.

TypeError: Argument 1 passed to Drupal\Core\Form\OptGroup::flattenOptions() must be of the type array, string given, called in C:\ExceedDrupal_1\web\modules\contrib\webform\src\WebformSubmissionGenerate.php on line 196 in Drupal\Core\Form\OptGroup::flattenOptions() (line 23 of C:\ExceedDrupal_1\web\core\lib\Drupal\Core\Form\OptGroup.php) #0 C:\ExceedDrupal_1\web\modules\contrib\webform\src\WebformSubmissionGenerate.php(196): Drupal\Core\Form\OptGroup::flattenOptions('compliance') #1 C:\ExceedDrupal_1\web\modules\contrib\webform\src\WebformSubmissionGenerate.php(108): Drupal\webform\WebformSubmissionGenerate->getTestValues(Object(Drupal\webform\Entity\Webform), 'personal_data_s...', Array, Array) #2 C:\ExceedDrupal_1\web\modules\contrib\webform\src\Plugin\WebformElement\WebformCompositeBase.php(807): Drupal\webform\WebformSubmissionGenerate->getTestValue(Object(Drupal\webform\Entity\Webform), 'personal_data_s...', Array, Array) #3 C:\ExceedDrupal_1\web\modules\contrib\webform\src\Plugin\WebformElementManager.php(234): Drupal\webform\Plugin\WebformElement\WebformCompositeBase->getTestValues(Array, Object(Drupal\webform\Entity\Webform), Array) #4 C:\ExceedDrupal_1\web\modules\contrib\webform\src\WebformSubmissionGenerate.php(186): Drupal\webform\Plugin\WebformElementManager->invokeMethod('getTestValues', Array, Object(Drupal\webform\Entity\Webform), Array) #5 C:\ExceedDrupal_1\web\modules\contrib\webform\src\WebformSubmissionGenerate.php(108): Drupal\webform\WebformSubmissionGenerate->getTestValues(Object(Drupal\webform\Entity\Webform), 'staff_file_requ...', Array, Array) #6 C:\ExceedDrupal_1\web\modules\contrib\webform\src\WebformSubmissionGenerate.php(80): Drupal\webform\WebformSubmissionGenerate->getTestValue(Object(Drupal\webform\Entity\Webform), 'staff_file_requ...', Array) #7 C:\ExceedDrupal_1\web\modules\contrib\webform\src\Element\WebformCodeMirror.php(307): Drupal\webform\WebformSubmissionGenerate->getData(Object(Drupal\webform\Entity\Webform)) #8 C:\ExceedDrupal_1\web\modules\contrib\webform\src\Element\WebformCodeMirror.php(190): Drupal\webform\Element\WebformCodeMirror::validateTwig(Array, Object(Drupal\Core\Form\FormState), Array) #9 C:\ExceedDrupal_1\web\modules\contrib\webform\src\Element\WebformCodeMirror.php(146): Drupal\webform\Element\WebformCodeMirror::getErrors(Array, Object(Drupal\Core\Form\FormState), Array) #10 [internal function]: Drupal\webform\Element\WebformCodeMirror::validateWebformCodeMirror(Array, Object(Drupal\Core\Form\FormState), Array) #11 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\Form\FormValidator.php(282): call_user_func_array(Array, Array) #12 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\Form\FormValidator.php(238): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState)) #13 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\Form\FormValidator.php(238): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState)) #14 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\Form\FormValidator.php(238): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState)) #15 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\Form\FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'webform_handler...') #16 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\Form\FormBuilder.php(576): Drupal\Core\Form\FormValidator->validateForm('webform_handler...', Array, Object(Drupal\Core\Form\FormState)) #17 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\Form\FormBuilder.php(319): Drupal\Core\Form\FormBuilder->processForm('webform_handler...', Array, Object(Drupal\Core\Form\FormState)) #18 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\Controller\FormController.php(93): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\webform\Form\WebformHandlerAddForm), Object(Drupal\Core\Form\FormState)) #19 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #20 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #21 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\Render\Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #22 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #23 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #24 C:\ExceedDrupal_1\vendor\symfony\http-kernel\HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #25 C:\ExceedDrupal_1\vendor\symfony\http-kernel\HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #26 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\StackMiddleware\Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #27 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #28 C:\ExceedDrupal_1\web\core\modules\page_cache\src\StackMiddleware\PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #29 C:\ExceedDrupal_1\web\core\modules\page_cache\src\StackMiddleware\PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #30 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #31 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #32 C:\ExceedDrupal_1\vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #33 C:\ExceedDrupal_1\web\core\lib\Drupal\Core\DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #34 C:\ExceedDrupal_1\web\index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #35 {main}.

CommentFileSizeAuthor
#6 3112015-6.patch1.1 KBjrockowitz
#4 test_form.yml25.23 KBnancydru

Comments

NancyDru created an issue. See original summary.

jrockowitz’s picture

Status: Active » Postponed (maintainer needs more info)

I am not sure how to reproduce this issue.

Please provide me with a simple example webform that I can use to reproduce this issue.

If you have an existing webform, you need to simplify it to only include the elements and settings which are needed to trigger the error.

My guess is a select menu with reusable options or custom code is triggering this issue. The error is definitely related to the #options property being a string.

nancydru’s picture

Having trouble shrinking the form, so I'm taking out one page at a time. At least that way I can isolate the problem.

nancydru’s picture

Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new25.23 KB

Okay, I think I have isolated it to the two custom composite pages (Staff File Requirements, Child File Requirements). If I remove both of them I am okay. With either, it fails.

nancydru’s picture

If you need the customized radio options, let me know.

Here's what I did:

  1. Click on "Add email"
  2. Select a role (in my case "Supervisor")
  3. Set CC to "current user email address"
  4. Turn off all of the included values
  5. Turn back on Visit date, name of licensor, program name, and provider ID.
  6. Click Save

.

jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new1.1 KB

The table element nested in a custom composite is not a supported behavior and this is triggering the error. The attached patch prevents the fatal error but does not add support for table elements nested in a custom composite.

My recommendation is to build a composite element via code, which will be more stable and customizable.

nancydru’s picture

Thanks. I will have to look at that because my boss is rather insistent on having this.

nancydru’s picture

Status: Needs review » Reviewed & tested by the community

Indeed the TypeError message is gone. Thanks.

When I completed the submission, I did get Notice: Undefined index: #webform_id in Drupal\webform\Plugin\WebformElement\ContainerBase->formatHtmlItem() (line 169 of modules\contrib\webform\src\Plugin\WebformElement\ContainerBase.php).. My test site seems to be unable to actually send email, so that may be the problem.

nancydru’s picture

When I reload the submission (which used "Test"), I receive a bunch of these:

Notice: Undefined index: #webform_id in Drupal\webform\Plugin\WebformElement\ContainerBase->formatHtmlItem() (line 141 of modules\contrib\webform\src\Plugin\WebformElement\ContainerBase.php).
Notice: Undefined index: #webform_id in Drupal\webform\Plugin\WebformElement\ContainerBase->formatHtmlItem() (line 147 of modules\contrib\webform\src\Plugin\WebformElement\ContainerBase.php).
Notice: Undefined index: #webform_key in _webform_theme_suggestions() (line 902 of modules\contrib\webform\includes\webform.theme.inc).
Notice: Undefined index: #webform_id in template_preprocess_webform_element_base_html() (line 425 of modules\contrib\webform\includes\webform.theme.template.inc).
Notice: Undefined index: #webform_key in template_preprocess_webform_element_base_html() (line 433 of modules\contrib\webform\includes\webform.theme.template.inc).

jrockowitz’s picture

Status: Reviewed & tested by the community » Needs work

You are using unsupported nested elements in the composite's #elements markup. I am not sure I can keep providing patches to work around this issue.

nancydru’s picture

I am replacing the table with just regular radios. The table wasn't really necessary.

nancydru’s picture

When you said "table" were you referring to "'#type': details", which would mean that one cannot include details within custom composite?

The customer really wants collapsible areas. Details is the only one I see that does that.

jrockowitz’s picture

Yes, the details in the custom composite is not supported in the UI.

nancydru’s picture

Actually, it appears that the UI does not support any type of container in a custom composite. Will using a simple "container" break things too?

jrockowitz’s picture

Here is a "legitimate hack". Instead of nesting the elements in a details element, the below code wraps the elements in details markup.

  custom_composite:
    '#type': webform_custom_composite
    '#title': custom_composite
    '#multiple__header': false
    '#element':
      textfield:
        '#type': textfield
        '#title': textfield
      email:
        '#type': email
        '#title': email
        '#prefix': '<details><summary>Details</summary>'
      number:
        '#type': number
        '#title': number
        '#suffix': '</details>'
nancydru’s picture

Thanks. I will give that a try.

nancydru’s picture

Status: Needs work » Reviewed & tested by the community

Perfect! I hadn't done the prefix/suffix trick since D6.

jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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