PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Conditional Shortcodes Bug and Documentation Clarification

  1. dnb
    Member

    Hi-
    I just spent a couple of hours fighting with conditional shortcodes in version 1.6.11 and in the process I think I've located both a real bug and an omission in the documentation. Let me mention my struggle with the documentation first because the other bug can be worked around.

    The documentation shows this:

    [gravityforms action="conditional" merge_tag="{Country:5}" condition="is" value="United States"]

    The place that I think it is very easy to get tripped us is the doc on first glance might lead you to believe that when you write merge_tag to reference a form field, the "value" attribute could be specifying the value of the field included by the merge tag, not the value that would be inserted by the merge tag. Now I know this is not the case.

    It's entirely possible this was just my own bias that caused me to think that something called 'value' in a shortcode would be same as what gets called a "value" in the form designer ("show values"). If the docs for the conditional shortcode could make it clear that the comparison gets done against the field label by default or field value if you add a :value to the merge_tag (perhaps with an example showing field:ID:value), that would have made a world of difference to me and perhaps others.

    So let's say you had a radio button form element like this:

    Form Element 6 "Where is Carl"
    "He is in Mexico again|MEXICO"
    "He is in a coffee shop|COFFEE"

    This means the conditional code has to say either:

    [gravityforms action="conditional" merge_tag="{Where is Carl:6}" condition="is" value="He is in Mexico again"]

    or

    [gravityforms action="conditional" merge_tag="{Where is Carl:6:value}" condition="is" value="MEXICO"]

    Ok, now the real bug:

    If you use a radio button element and have a field label that includes an apostrophe, the conditional shortcode logic breaks in a very interesting way. Even if you insert that apostrophe not as a single quote, but as the HTML entity it still breaks. I found that it never properly does a comparison. So in the example above, if the form element was:

    Form Element 6 "Where is Carl"
    "He is in Mexico again|MEXICO"
    "He is cryin' in his coffee|COFFEE"

    (in my case the actual Field label was [Second Line Social Aid and Pleasure Society Brass Band: "I Feel Like Funkin’ It Up"])

    you will find that any comparison, even for a different value in the same element, like this from above:

    [gravityforms action="conditional" merge_tag="{Where is Carl:6:value}" condition="is" value="MEXICO"]

    will not succeed. My theory is the code that parses merge tags throws up its hands if it finds an extra quote, but that's only a guess. I haven't had a chance to dig through the code to confirm this.

    Anyway, thanks for all of the hard work putting in the conditional shortcode functionality. Now that my head is screwed on right about it, it rocks.

    -- dNb

    Posted 11 years ago on Sunday December 23, 2012 | Permalink
  2. I'll bring your topic to the attention of the development team.

    Posted 11 years ago on Sunday December 23, 2012 | Permalink
  3. @dNb
    Thanks for the very detailed explanation. I agree with you on the first issue. The usage of "value" does seem a little misleading in that scenario and we will be looking at adding some sort of message to the documentation to make that a bit more clear.

    As far as the bug, I will try to track it down and get back to you when I have it fixed.

    Posted 11 years ago on Wednesday December 26, 2012 | Permalink