Problem/Motivation
When trying to add a form translation, the following error is thrown:
TypeError: Argument 1 passed to Drupal\Core\Render\Element::children() must be of the type array, null given, called in /app/modules/contrib/webform/src/WebformTranslationConfigManager.php on line 325 in Drupal\Core\Render\Element::children() (line 71 of /app/core/lib/Drupal/Core/Render/Element.php)
Steps to reproduce
- Install Drupal; tested on 9.1.8 and 8.9.15
- Install language and configuration translation
- Add a second language; ES
- Install of webform 6.0.3
- Add a new webform; /admin/structure/webform/add; test1
- Translate the webform; /admin/structure/webform/manage/test1/translate/es/add
- Result: The website encountered an unexpected error. Please try again later.
Log error message:
TypeError: Argument 1 passed to Drupal\Core\Render\Element::children() must be of the type array, null given, called in /app/web/modules/contrib/webform/src/WebformTranslationConfigManager.php on line 325 in Drupal\Core\Render\Element::children() (line 71 of /app/web/core/lib/Drupal/Core/Render/Element.php)
Testing the commits, the issue occurs from dev-6.x#2e3620e9
Error does not occur on 6.0.2 or dev-6.x#265d0a69
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 3212867-19.patch | 751 bytes | gooddev |
| #18 | 3212867-16.patch | 756 bytes | gooddev |
| #7 | php_error.txt | 4.81 KB | lomale@bluewin.ch |
| #6 | Rueckmeldefragebogen.txt | 7.68 KB | lomale@bluewin.ch |
| #3 | webform.webform.3212867.yml | 4.64 KB | paulocs |
Issue fork webform-3212867
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 #2
jrockowitz commentedSorry about the fatal bug.
Would you be able to post an example webform that can be used to replicate this issue?
Comment #3
paulocsAttaching webform to reproduce the error and patch.
Comment #4
james.shee commentedSorry about the confusion on the webform configuration. The error occurs even on an empty webform.
Tested patch from #3 works for webforms with elements; however, found another issue with empty webforms.
Scenario 1: Working
Webform contains elements
Result:Webform Test1 elements saved.
Scenario 2: Broken
Webform is empty
Result: The website encountered an unexpected error. Please try again later.
Log messages:
This issue is present going back to 6.0.0
Comment #5
paulocsYeah! If the webform is empty (no elements) the error #4 occurs but it is not related with #3202515: Translation of custom body of email handler does not show as CKEditor.
was introduced in #3172735: Improve webform elements translation UI and refactor webform translation code
Comment #6
lomale@bluewin.ch commentedHi, i hang into this
Drupal-Version: 8.9.15
PHP Version 7.4.16
Webform 6.0.3
I had the same problem, with a questionaire. file appended.
I hat it translated with not processed_text field in the questionaire.
Then I wanted to have this changed.
1 error : Processed text element can not be opened within a modal. Please see Issue #2741877: Nested modals don't work.
2 I couldn't open the translate option
I deleted the english translation, to translate it again.
Then I couldn't even come back to the translation.
The website encountered an unexpected error. Please try again later.
i had to rewrite the form and was then able to translate it with out processed text element.
Just as information
I will also append the php error
Comment #7
lomale@bluewin.ch commentedhere the php Error txt
Comment #8
paulocsHello @lomale@bluewin.ch,
Did you try patch #3?
Comment #9
james.shee commented@paulocs Ah, ok. Separate issue then. Going to update status to reviewed and tested by the community. Appreciate your fix and clarification.
Comment #10
paulocsI opened another issue for when webforms have no elements.
#3213178: Unable to translate webforms if it has no elements.
Comment #11
joseph.olstadRTBC +1, needed this fix for reasons described above
Thanks everyone!
If I don't apply patch 3, I get a nasty error below:
Comment #12
jrockowitz commentedComment #15
rar9 commentedpatch 3# not cant be applied... is it because we still use 6.0.3 vs dev?
Is the 2x patched patch also required for a FUNCTIONAL Webform?
Comment #17
gooddev commentedI recognized following error when saving the translation of a webform with custom elements in it.
TypeError: Argument 2 passed to Drupal\webform\WebformTranslationConfigManager::mergeTranslationAndSourceElementsProperties() must be of the type array, string given, called in /var/www/html/web/modules/contrib/webform/src/WebformTranslationConfigManager.php on line 1032 in Drupal\webform\WebformTranslationConfigManager->mergeTranslationAndSourceElementsProperties() (line 1022 of modules/contrib/webform/src/WebformTranslationConfigManager.php).so i added a type check for "$source_element" to get sure this is an array. (see patch 3212867-16.patch).
Comment #18
gooddev commentedComment #19
gooddev commentedsorry for the spam, cannot override wrong patch, here is the correct one now "3212867-19.patch"
Comment #20
jrockowitz commented@dev.tim Your patch makes perfect sense. I am willing to bet all the tests pass.
Comment #22
jrockowitz commentedComment #23
daften commentedCan I ask why 2 separate issues were fixed in the same issue? This makes it quite hard to figure out what patch to use when still on 6.0.3. Luckily this was a short comment list, but imo this should be avoided. The issue reported in #3212867-17: Unable to translate webforms 6.0.3 should have been a separate issue.
Comment #25
ShenHua commentedThis is still broken in 6.0.4. Even tho the #19 patch is already implemented.I am getting:----
The condition for this error to appear is probably why this was missed.In general, I am able to translate the webform.BUTAfter I add the TWIG template to the body of the message in email handlers. Then I get this error whenever I try to translate from that point on.Possible duplicate: (I am going to check if the patch there helps, and report back, also, if you need any more code from me let me know).https://www.drupal.org/project/webform/issues/3215471UPDATE:
I am still experiencing the same error as #4 of issue 3215471.Both the patch from here, and the patch from there are already implemented in 6.0.4, so they're not solving the issue.UPDATE:
Good news! Turns out that the issue was with my TWIG code.
The problem is that the TWIG code "worked" for sending the email and there was nothing notifying me that there's a mistake... until I reached the translate step.
Anyway, the issue was that there were some parts of the code resulting in NULLS (obviously when I look at it now):
wrong:
{{ webform_token('[webform_submission:values:message]', webform_submission, [], options) }}correct:
{{ webform_token('[webform_submission:values:message]', webform_submission) }}Comment #26
leup commentedThank you @ShenHua ! You saved me a lot of time, I had the same issue and was able to fix it with your solution. Again, thanks !