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
- Create a new webform; /admin/structure/webform/add
- Name it whatever you want; "hierarchy 1"
- 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 - Navigate to the sharepoint_connector configure webform page; admin/config/sharepoint_connector/settings/webforms/configure?id=hierarchy 1&machine=hierarchy_1
- Result: only see top level fields; checkbox1, page1, Created
- 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:
- 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.
- Should also look at how the webform title and id are being passed in.
- /admin/config/sharepoint_connector/settings/webforms/configure returns a null error since the parameters are not present
- 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
Issue fork sharepoint_connector-3497230
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
Comment #4
robbymo commentedThank 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!