Nesting Condition frm-condition in Views doesn't seem to work

By: Daveed Flexer | Asked: 12/19/2022
ForumsCategory: Code HelpNesting Condition frm-condition in Views doesn't seem to work
Daveed Flexer asked 2 years ago

I need to have conditions nested in a view eg

[frm-condition ......]
[frm-condition ......] Yes to both [/frm-condition]
[/frm-condition]

This doesn't work. Is there another to have nested frm-condition?

2 Answers
Victor Font answered 2 years ago
There's nothing in the Knowledgebase about nesting this shortcode. It's used for comparing two values only. https://formidableforms.com/knowledgebase/compare-two-values-for-display/. If you need something more complex, you should write your own shortcode.
Daveed Flexer replied 2 years ago

Thank you Victor. In case this helps someone I ended up with a combination of named param and a a simple [if]
It might be easier to create a shortcode, but for now this works.
====
[frm-condition source=param param=actual_number equals=0]
[if 26 like="Yes"]
/// Display
[/if 26]
[/frm-condition]
===

Chris Titus replied 1 year ago

Does this still work for you? I am seeing errors. My [if] statements are displayed on the page.

Daveed Flexer replied 1 year ago

<p><p>Hey @bookclubreading I did this so long ago, but it did end up making it work but I think there was more to just this part. And custom parameters were certainly the answer. I made a bunch of these.</p><pre>Start your code here[frm-condition source=param param=monetary_difference equals=0] [if 27 22="Plaintiff" like="Yes"] [frm-math]([frm-stats id=24 type=total 25="[25]" 22="Defendant"] - [frm-stats id=24 type=total 25="[25]" 22="Plaintiff"])[/frm-math] [/if 27] [/frm-condition]</pre><pre>Start your code here</pre><p>I'll try to look at the rest of the code as soon as I can and see what I can (re)learn.</p></p><p>Not sure why the formatting is messed up</p>

Chris Titus replied 1 year ago

Hi Daveed - Thanks for your response. Unfortunately, it didn't work for me. I need another frm-condition statement to count instances of a field value in another form

Jason LoftusJason Loftus answered 3 months ago

I realize this answer is late to the game, but thought it might be useful to anyone else that needs help with this. My method of addressing this uses alternate views nested within the conditionals. I've successfully used this method for several different sites, but I don't believe it's officially supported. You can add several layers of nesting (Conditional Inception), but things get exponentially more difficult to manage and keep straight with each new layer. Sorry about any weird text formatting; apparently I do not know how to use a simple text editor.

VIEW ID 1000
[frm-condition source=frm-field-value field_id=100 equals="Condition A"]
[display-frm-data id=2000 send_param="[99]"]
[/frm-condition][frm-condition source=frm-field-value field_id=100 equals="Condition B"]
[display-frm-data id=3000 send_param="[99]"]
[/frm-condition]

VIEW ID 2000  
{filtered field 99 to [get param=send_param]}
{limit of 1}
[frm-condition source=frm-field-value field_id=200 equals="Condition C"]
Condition A and Condition C have been met
[/frm-condition][frm-condition source=frm-field-value field_id=200 equals="Condition D"]
Condition A and Condition D have been met
[/frm-condition]

VIEW ID 3000
{filtered field 99 to [get param=send_param]}
{limit of 1}
[frm-condition source=frm-field-value field_id=200 equals="Condition C"]
Condition B and Condition C have been met
[/frm-condition][frm-condition source=frm-field-value field_id=200 equals="Condition D"]
Condition B and Condition D have been met
[/frm-condition]

Victor Font replied 3 months ago

The Formidable Forms Codex V2 uses triple nested views. The problem with triple nested views is long term performance. As the database grows, so does the time to display your content.

Codex V2 has 10,844 entries covering every class,, method, action, and filter found in Formidable's source code and every add-on available to an Elite license.

When I built the triple nested views, I only rolled out the actions and filters views. Classes and functions were so slow, I left the original V1 views in place.

There are ways to improve performance by taking advantage of the frm_view_order filter and using genuine SQL Views you create in the RDBMS instead of running Formidable's generated SQL every time the view is accessed.

Jason LoftusJason Loftus replied 3 months ago

I have noticed performance degradation with larger datasets and several nested views so I try to use this technique sparingly and only when I’m unable to find alternative compromises. Do I understand that the limit in the current release is 3 nested views?

Victor Font replied 3 months ago

I don’t know of a nesting limit.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right