Problem/Motivation

Not all webform fields show up under admin/config/sharepoint_connector/settings/webforms/configure?id=[webform title]&machine=[webform id]

Steps to reproduce

  1. Create a new webform; /admin/structure/webform/add
  2. Name it whatever you want; "hierarchy 1"
  3. Add in nested elements;
    checkbox1:
      '#type': checkbox
      '#title': checkbox1
    flexbox1:
      '#type': flexbox
      textarea1:
        '#type': textarea
        '#title': textarea1
    page1:
      '#type': wizard_page
      '#title': page1
      textarea2:
        '#type': textarea
        '#title': textarea2
  4. Navigate to the sharepoint_connector configure webform page; admin/config/sharepoint_connector/settings/webforms/configure?id=hierarchy 1&machine=hierarchy_1
  5. Result: only see top level fields; checkbox1, page1, Created
  6. Expected result: see all fields; checkbox1, textarea1, page1, textarea2, Created

Proposed resolution

/src/Form/SharepointConnectorFormWebformFields.php
Instead of using

$webform_fields = $webform->getElementsDecoded();

Use

$webform_fields = $webform->getElementsDecodedAndFlattened();

getElementsDecoded returns:

Array ( 
  [checkbox1] => Array ( 
    [#type] => checkbox 
    [#title] => checkbox1 ) 
  [flexbox1] => Array ( 
    [#type] => webform_flexbox 
    [textarea1] => Array ( 
      [#type] => textarea 
      [#title] => textarea1 ) ) 
  [page1] => Array ( 
    [#type] => webform_wizard_page 
    [#title] => page1 
    [textarea2] => Array ( 
      [#type] => textarea 
      [#title] => textarea2 ) ) ) 

Whereas getElementsDecodedAndFlattened returns

Array ( 
  [checkbox1] => Array ( 
    [#type] => checkbox 
    [#title] => checkbox1 ) 
  [flexbox1] => Array ( 
    [#type] => webform_flexbox ) 
  [textarea1] => Array ( 
    [#type] => textarea 
    [#title] => textarea1 ) 
  [page1] => Array ( 
    [#type] => webform_wizard_page 
    [#title] => page1 ) 
  [textarea2] => Array ( 
    [#type] => textarea 
    [#title] => textarea2 ) ) 

Alternative:
We could modify foreach to drill down into the array, but the current implementation does not account for hierarchy and I do not currently see a use case to do so.

Notes, out of scope for this issue:

  1. We should also exclude "webform_wizard_page" as an element type; reason: this contains no value and is just for layout purposes. Need to see if there is a way to identify layout elements.
  2. Should also look at how the webform title and id are being passed in.
    1. /admin/config/sharepoint_connector/settings/webforms/configure returns a null error since the parameters are not present
    2. Typically I have seen parameters passed as just part of the URL, something like /admin/config/sharepoint_connector/settings/webforms/[webform id]. This would eliminate a need to catch an exception as that path would no longer exist. The additional change would be to get the webform title from the webform entity.

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

james.shee created an issue. See original summary.

  • robbymo committed 0ef8dcbe on 1.0.x
    Issue #3497230 Allowing webform fields to be flattened before processing
    
robbymo’s picture

Assigned: Unassigned » robbymo
Status: Active » Fixed

Thank you for your contribution james.shee! This has been tested and merged in with an additional update to the webform processing to also use getElementsDecodedAndFlattened(). A new release has been created to reflect these changes.

Please feel free to add additional tickets as feature requests for other items that you'd like to see. Thanks!

Status: Fixed » Closed (fixed)

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