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.

Comparing between two fields in conditional logic?

  1. Gaslight

    For a series of custom post types where I have a gravity forms attached, I would have stored some meta fields containing dates, which I can format as simple integers ($dd, $mm, $yyyy)

    I need to create a list of "high seasons" for a tourism ecommerce setup. Each custom post type could have its own "high season" period and I can specify that with date ranges.

    Based on these ranges I'd with to show/hide certain fields in the related gravity form appearing on the post.

    I know how to populate fields in a gravity form, but in this case it's about conditional logic.

    Suppose I populate a hidden field [1] with a $mm (month value).

    Then suppose I have two more fields in the form:

    [2] one is a month dropdown
    [3] the other is a normal field that would show up only if month dropdown value [2] == hidden field value [1]

    that is if month value set in custom field and assigned to field [1] is identical to value chosen by user for field [2]

    Carl told me that I can't pass PHP into conditional logic

    but in this case I wonder if there's any internal variable that can compare two fields in the same form, for example if there's anything else than a specific value I can put in the conditinal logic fied

    if this is not possible either, what would you suggest me to do? any ideas are greatly appreciated...

    thank you

    Posted 7 years ago on Tuesday February 21, 2012 | Permalink
  2. Gaslight

    I just found this post in the documentation

    I don't get it... it means I can actually set my own conditional logic for example in a gform_pre_render? if is it that so, then I would have solved by problem since i could pass the values I need in the "rules" array

    Posted 7 years ago on Tuesday February 21, 2012 | Permalink
  3. You are correct, I was a bit confused by your original request.

    You can use the gform_pre_render hook to change conditional logic using custom PHP. That is where this documentation comes in, although the documentation you reference wasn't a standalone page... it's part of the Field Object documentation here:

    So by itself, it's a bit out of context.

    But yes, it can be used to customize the conditional logic for the form using custom code.

    HOWEVER, I realized after trying to find a way for you to accomplish conditionally showing or hiding fields based on the value of post meta without using custom code *IF* you are using Gravity Forms v1.6.3 Beta 2.

    - Edit your form
    - Add a Hidden Field to your form
    - Edit this new Hidden Field
    - Give the Field Label whatever you want to call it
    - Select the Advanced Tab
    - In the Default Value enter the merge tag for custom meta and the meta name of the post meta you want to return the value of. For example, if the custom field name for the meta I wanted to return is "test" the merge tag would look like this:

    - Save Your Form

    Now you can use the built in conditional logic by editing the fields you want to show or hide and configuring conditional logic to use the new Hidden Field you created as part of the condition.

    Even though it is a hidden field, it will still trigger conditional logic because conditional logic executes when the form is rendered and because the hidden field will be populated with the value you want... the conditional logic will be triggered based on it.

    Posted 7 years ago on Tuesday February 21, 2012 | Permalink
  4. Gaslight

    awesome! :)

    thanks for the extra effort finding another solution to my problem

    for now I'm forced to stick to 1.6.2 because the WooCommerce Extension is not supporting 1.6.3b (but I guess they will soon, they're rewriting the extension for GF, so I have heard)

    I'm happy these two great plugins can work well together!

    Posted 7 years ago on Tuesday February 21, 2012 | Permalink
  5. aabz-imaging

    Hi Carl, my query goes into the same direction, but I am no where near as knowledgeable as Gaslight when it comes to programming.
    I need the form to display an alert that the selected dates (check-in & check-out) in the two date fields are outside the season and that a different date needs to be selected.
    I've created two normal date fields and two hidden fields, which get populated dynamically with the data from these fields once the person fills them in (I assume this this is possible?). No I am trying to trigger conditional logic to display and HTML Block with the message.
    The date fields are set to dd/mm/yyyy - how do I set the conditional logic to trigger for a date entered before 01st of April and after 15th July? Or am I on the wrong track here??

    Posted 7 years ago on Monday August 13, 2012 | Permalink