This project is no longer maintained and no further public releases are planned.

No further support will be given.

Feel free to fork the git repository.

How to set up a multistep form with conditions

Create  normal Formhandler TypoScript setup and add conditions and change the settings plugin.Tx_Formhandler.settings.[stepnumber].templateSuffix.

 

How the conditions work:

plugin.Tx_Formhandler.settings {
  if {
    1 {
      conditions.OR1.AND1 = field1=value1
      isTrue {
        # Make settings for a different step 3
        3 {
          templateSuffix = _alternative
          validators.1.config.disableErrorCheckFields = firstname,lastname,email
        }
      }
      else {
        # Do something if the condition was not true. This will not be needed often.
      }
    }
    2 {
      conditions.OR1 {
        AND1 = age<21
        AND2 = product=alcohol
      }
      isTrue {
        templateSuffix = _underage
        validators.1.config.disableErrorCheckFields = firstname,lastname,email
      }
      else {
        # Do something if the condition was not true. This will not be needed often.
      }
    }
  }
}

Using the “if” setting you can specifiy conditions for GET/POST parameters. If the conditions are TRUE, the settings in “isTrue” will be merged with the original Formhandler settings.

The conditions can be specified in two levels. Level 1 will be OR conditions, level 2 will be AND conditions.

Example:

plugin.Tx_Formhandler.settings {
  if {
    1 {
      conditions {
        OR1 {
          AND1 = field1=value1
          AND2 = field2=value2
        }
        OR2 {
          AND1 = field3=value3
        }
      }
    }
  }
}

This will result in the following final condition:

(field1 == 'value1' && field2 == 'value2') || (field3 == 'value3')

You can use the following operators:

=, <, >, !=

NOTE: If you don't use an operator, Formhandler will check if the field is set in GET/POST.

NOTE: You can use the '|' operator to access values in an array like in a normal TypoScript context.

NOTE: Using the TypoScript setting 'templateSuffix', you can define different templates for your steps, emails and PDFs. If you have a form with 3 steps and you want to send emails and PDFs according to the chosen route, you can set the templateSuffix option for step 4 to to ensure that the correct template for emails and PDFs is set.


to top