I have a webform with a nested field structure, so I have a number of fieldsets and then textfields or whatever within them. Not all of the fields are mandatory.
Then when the form is submitted I'm using the following token to print the entered value for one of the optional textfields: %value[fieldset1][address2]
According to the code, all empty fields have their tokens replaced with an empty string, but what is actually happening in my case is that %value[fieldset1] gets replaced with an empty string and the [address2] is still appears in the email text.
This is because the replacement for %value[fieldset1] happens first. Really we should replace all children first, and then work our way up to the parents. The attached patch fixes the problem for me. It reverse sorts the email replacements array on its key, meaning longer keys are replaced first, and since a child will always have a longer key than its parent, I think this should work quite well.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | partial_replacements3-18.patch | 526 bytes | sridharpandu |
| partial_replacements.patch | 584 bytes | stella |
Comments
Comment #1
Punk_UnDeaD%value[hidden][summa_zayma] not replaced for anonimous
I use dirty code
if (!$user->uid) $user->uid=-1;before call _webform_filter_values();---
Sorry for my english.
Comment #2
quicksketchLet's merge with #1332820: Parts of nested tokens (in fieldsets) printed when left empty
Comment #3
sridharpandu commentedStill unresolved in version 3.18. Trying to patch the module file. Any help will be appreciated.
Comment #4
sridharpandu commentedJust add this line krsort($replacements['email'][$format]);
after
$replacements['email'][$format]['%value[' . $form_key . ']'] = '';
}
and before
// Submission edit URL.
Will post the patch soon.
Comment #5
sridharpandu commentedHere is the patch for 3.18