Put quotes around parameter shortcodes

Labels

This Discussion is public

Notifications

When I use this inside of a shortcode in a View:

1108=[get param=provincename]

things worked fine, until one of the values getting passed for the provincename contained a space. The lack of quotes around the square brackets ended up corrupting the value (I'm assuming the space indicates the end of the variable?), so my results were wrong.

Until I changed it to this: 1108="[get param=provincename]"

I'm assuming that we should put the quotes around every value, but someone please correct me if that's wrong.

Normally, the way to pass multi-word query string parameters is to url encode the spaces. You don't mention how you are getting the provincename variable, whether by text input or dropdown. Either way, when the field changes, I would take the value, encode it, and store it in a hidden field. Then I would use the hidden field as the query string parameter. Formidable should decode the value. If encoded in PHP, use rawurlencode(). In Javascript, use encodeURI().

In jQuery, your function would look something like this:

$("#source_field_id").on("change", function() {
$("#target_field_id").val( encodeURI( $(this).val() ) );
});

Of course, this code isn't tested, but it should give you a general idea of how this is done.

Reply to this Discussion