Forum

Thread tagged as: Question, Problem, Forms

Nesting if statements

Hi Perch,

I'm having a problem with nesting if statements. Basically I have a form that I only want to show in certain circumstances.

The form is connected to both Forms app and Mailchimp app. However I only want the data to be sent to Mailchimp if the user checks off a checkbox (newsletter signup).

My problem is that if I nest the <perch:if> my outer most if-statements stop working.

This is my markup:

<perch:if id="end_date" match="gt" value="{current_date}"> (current_date is set with PerchSystem::set_var)

 <perch:if exist="checkbox">

<perch:form id="konkurrence" app="perch_mailchimp perch_forms" double-optin="false" send-welcome="true">

<perch:else />

<perch:form id="konkurrence" app="perch_forms" double-optin="false" send-welcome="true">

</perch:if>

...Rest of the form

</perch:if>

I would like to note that the region is created using perch_content_create and called with perch_content_custom and before adding the second if-statement <perch:if id="end_date" match="gt" value="{current_date}"> worked perfectly.I hope some one is able to point me to a solution to this problem.

Thanks in advance :)

Alexander Carlsen

Alexander Carlsen 0 points

  • 7 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

You are using if exist and not if exists however I don't think what you are doing will work.

I wrote up how to do this for comments here: https://grabaperch.com/blog/archive/add-a-blog-commenter-to-a-mailchimp-list