diff --git a/webform.module b/webform.module index 2559527..c2eb9a1 100644 --- a/webform.module +++ b/webform.module @@ -3041,6 +3041,11 @@ function _webform_filter_values($string, $node = NULL, $submission = NULL, $emai // incomplete objects (see http://php.net/is_object), so we check // for simple types instead. $replacement = (is_string($value) || is_bool($value) || is_numeric($value)) ? $value : ''; + + // Add support for arrays in token replacement + if (is_array($value)){ + _webform_filter_values_array($replacements[$safe_state], $token, array($key),$value); + } } $replacements[$safe_state][$token . '[' . $key . ']'] = $replacement; } @@ -3081,6 +3086,24 @@ function _webform_filter_values($string, $node = NULL, $submission = NULL, $emai } /** + * Provides support for arrays in replacement tokens + */ +function _webform_filter_values_array(&$replacements, $token, $keys, $values) { + if (is_array($values)) { + foreach ($values as $key => $value) { + // Recursive behaviour + _webform_filter_values_array($replacements, $token, array_merge($keys, array($key)), $value); + } + } + elseif (is_object($values)) { + //$replacements[$token.'['.implode('][',$keys).']'] = ''; + } + else{ + $replacements[$token . '[' . implode('][', $keys) . ']'] = $values; + } +} + +/** * Filters all special tokens provided by webform, and allows basic layout in descriptions. */ function _webform_filter_descriptions($string, $node = NULL, $submission = NULL) {