I'm using the module to customize forms generated from a "Base Form" defined with Webform Default Fields.
Sometimes, after save multiple changes (move, modify, add or delete fields) on a form, it crashes with errors like
Notice: Undefined index: element_id a FormBuilderFormBase->_recursiveElementIds() (line 670 of .../sites/all/modules/form_builder/form_builder.classes.inc).
or
Fatal error: Call to a member function render() on a non-object in .../sites/all/modules/form_builder/form_builder.classes.inc on line 737
Analyzing it I found that, for some reason, an element with an empty key is generated causing errors on the code. My patch don't fix the generation of this empty elements but avoid the errors
Comment | File | Size | Author |
---|---|---|---|
#8 | 2733829-8-avoid-setting-weight-of-deleted-elements.patch | 1.02 KB | torotil |
#6 | fix_duplicate_keys_in_the_same_scope.patch | 1.08 KB | inhelli |
Comments
Comment #2
mls09121 CreditAttribution: mls09121 commentedI'm not to familiar with adding patches, but I'm having the same issue. Its actually quite a terrible bug because it blocks you from even using the regular webform-- you have to disable the module. I get:
Notice: Undefined index: element_id in FormBuilderFormBase->_recursiveElementIds() (line 670 of /var/www/html/public_html/sites/all/modules/form_builder/form_builder.classes.inc).
Notice: Undefined index: element_id in FormBuilderFormBase->_recursiveElementIds() (line 670 of /var/www/html/public_html/sites/all/modules/form_builder/form_builder.classes.inc).
I'm confused as to where to paste the code from the patch though. Could you please explain? There are a number of different files in the module folder.
Thank you!
Comment #3
fcasanellas CreditAttribution: fcasanellas commentedIt's easy, just edit the file form_builder.classes.inc replacing the line 669 that contains
if (isset($e[$key]['#form_builder'])) {
for:
if ($key && isset($e[$key]['#form_builder'])) {
Comment #4
genjohnson CreditAttribution: genjohnson at The University of Iowa commentedChanging status to "needs review" since a patch has been provided.
Comment #5
torotil CreditAttribution: torotil at more onion commentedHi first thanks for your work on this!
If the problem is that an empty element is created at some point then that's the problem to solve. A patch that covers symptoms is always a bad idea. So any idea how/why this empty element is created?
Comment #6
inhelli CreditAttribution: inhelli commentedCause is moving components with same keys in one scope (page or fieldset)
I tried to solve it this way:
Comment #7
torotil CreditAttribution: torotil at more onion commentedThanks @inhelli for your patch. I still don't quite understand what triggers this bug. Could you describe a simple test-case for me?
Comment #8
torotil CreditAttribution: torotil at more onion commentedOk I've found a test case on my own now:
You need at least 3 fields for this to work. Then in one form session do:
This fails because the position form in the browser is not updated after an element is deleted - and later when the positions form is submitted it sets the weight/parent of the now non-existent element (creating a broken element) and thus causing the failure.
Here is patch that fixes this.
Comment #9
JayKandariThis works as expected in latest release of form_builder 7.x-1.20.
Comment #10
grahamCI can see the patch from #8 was committed (http://cgit.drupalcode.org/form_builder/commit/?id=e27755a) and made it into 7.x-1.20, so let's call this fixed.