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.
For exapmle when you have: ?country[]=argentina&country[]=uruguay
Is this supposed to work, how?
Comments
Comment #1
hanoiiI found a possible fix for this on one line, not sure if this might be considered, if so, can provide a patch, is one line though:
function _webform_filter_values() 2649:
for
I rather not have a patched version of webforms for now for this as I can come up with alternatives, but any thoughts?
Comment #2
quicksketchI don't think this would work for most form elements. Since you'd need the default value to be an actual array for something like checkboxes or a multi-value select list. If you just wanted a comma-separated list you could do
?country=argentina,uruguay
in your URL.Comment #3
hanoiiExcept when I don't control the url, like with views and exposed filters. I am doing a webform that, among other things, captures the exposed filters used of a view. Anyway, I managed to do it by working out something on the submission hook, basically I added something like: %get[xx](multiple) to the token so that I can replace that with a CSV of the arguments. Maybe this only for textfields, but I see there might be little use for this.
Comment #4
quicksketchI'm changing this into a feature request, since Webform certainly doesn't advertise it's capable of handling array default values and this will require some tricky handling to make it work consistently with single-value and multiple-value fields alike.
Comment #5
m-patate CreditAttribution: m-patate commentedHi quicksketch,
I've posted some code on the issue "Webform tokens (%session, %post) do not support arrays" that can answer to this request. Could you have a look ?
I think it can answer to the "Add support for user Field module fields e.g. %profile[field_name]"
Thanks
Comment #6
quicksketchI'm sure this is the last thing Dave Reid wants, but due to #1001798: Rewrite token replacement system to use D7 tokens, this problem has now fallen to Token module, which provides [current-page:query:x] tokens (which also don't support arrays currently).
For Webform 3.x, please follow up in #824606: Webform tokens (%session, %post) do not support arrays (though I'm not sure 3.x will ever be fixed with this particular problem).
Comment #7
Dave ReidI'm wondering how these tokens would be output in this case? If we can define that then I can begin to support it.
Comment #8
quicksketchDave: I'm guessing that for array-structured GET tokens (like the one in the original post), it would make sense to implode them all together with commas by default and make it possible to implode with other characters if desired, something like [current-page:query:foo:implode:;]. Don't we have a similar syntax somewhere else in Token for imploding lists? I can't remember where I've seen this.
Comment #9
DamienMcKennaDoes Token have a standard solution / pattern for accessing specific elements of an array value?
Comment #10
attiks CreditAttribution: attiks commented#9 AFAIK token has support for array, it introduces a token type 'array' as the following (see token.tokens.inc)
Comment #11
kkalaskar CreditAttribution: kkalaskar commentedI am facing same problem with
?title=Carpet%20Cleaning&field_geofield_distance[distance]=30&field_geofield_distance[origin]=33314. I want to use 33314 field_geofield_distance[origin] this token but couldn't found any solution to it, so I installed module Custom Tokens. After enabling module /admin/structure/token-custom Create new token with PHP text format
Now I get token in Custom