Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The following form component tree (two levels):
Is not formatted correctly at the Included email values section:
This happens because the number of indentation marks for all children is always 1. And the reason of this is that the regular expression that removes the hyphens of each children component removes them in a single replacement. This is done at includes/webform.components.inc at :
$indents = 0;
$label = preg_replace('/^([\-])+/', '', $label, -1, $indents);
In the above line, if $label is "--Textfield", $indents will not get a value of 2, but a value of 1 as the hyphens are all matched as a single group.
A patch is being attached in the next comment.
Comment | File | Size | Author |
---|---|---|---|
#1 | fix_indentation_in_included_email_values_1398142_1.patch | 746 bytes | juampynr |
included_email_values.png | 16.27 KB | juampynr | |
form_components.png | 14.78 KB | juampynr |
Comments
Comment #1
juampynr CreditAttribution: juampynr commentedPatch that fixes this issue. I could not find a way with a regular expression that replaces hyphens one by one so the replacement count gets a correct value. That is why I am comparing the length of $label with itself after being truncated.
Comment #2
juampynr CreditAttribution: juampynr commentedChanged status to needs review
Comment #3
quicksketchThanks juampy. I finally had a chance to review this patch and it looks great. You were spot-on with why the current approach fails. I committed this patch but removed the last "-1" parameter, since preg_replace() defaults to -1 for the $limit parameter already.
Comment #4
juampynr CreditAttribution: juampynr commentedGreat news.