in2code/powermail_cond

Add conditions (via AJAX) to powermail forms for fields and pages

Installs: 372 353

Dependents: 0

Suggesters: 0

Security: 0

Stars: 8

Watchers: 14

Forks: 23

Open Issues: 15

Type:typo3-cms-extension

11.2.4 2024-11-28 15:36 UTC

README

Conditions for TYPO3 extension powermail. While a user fills out a form, some fields should disappear, while others should be visible.

⚠️ TYPO3 13 compatibility
See EAP page (DE) or EAP page (EN) for more information how to get access to a TYPO3 13 version

Screenshots

Example form with conditions

Backend view to records

Backend view to records with rule

List of Conditions you can apply on the powermail form fields

  • is set
  • is not set
  • contains value
  • contains value not
  • is
  • is not
  • is greater than (numbers only)
  • is less than (numbers only)
  • contains value from field
  • contains not value from field

Quick installation

Quick guide:

  • Just install this extension - e.g. composer require in2code/powermail_cond
  • Clear caches
  • Add a powermail form to any page
  • Add a new record from type "condition container" to a sysfolder and configure it
  • Don't forget to include the static template from powermail_cond
  • Don't forget to add jQuery to your frontend (if not yet installed)

Example routing configuration for TypeNum 3132:

...
rootPageId: 1
routes:
  -
    route: robots.txt
    type: staticText
    content: "Disallow: /typo3/\r\n"
routeEnhancers:
  PageTypeSuffix:
    type: PageType
    default: /
    index: ''
    suffix: /
    map:
      condition.json: 3132
...

Trouble shoot: upload fields

For being able to evaluate the conditions on the backend the form data gets sent as payload to the conditions.json route. In case of upload files (a.k.a [type=file]) the entire set of selected files are being uploaded with every change of basically every input field. This is resource and time consuming.

In case you don't rely on upload field within your set of conditions you can exclude them from being sent to the backend. To do so just specify add a parameter data-powermail-cond-excluded-fields-selector to the form template, e.g.

<f:form
    action="{action}"
    section="c{ttContentData.uid}"
    name="field"
    enctype="multipart/form-data"
    additionalAttributes="{vh:validation.enableJavascriptValidationAndAjax(form:form, additionalAttributes:{data-powermail-cond-excluded-fields:'.powermail_file'})}"
>

Local Development and Contribution

There is a docker based local development environment available. See Readme.md for more information.

Less flickering

To prevent the flickering that occurs when loading a form with conditions the usually asynchronously loaded "condition JSON" can be rendered directly into the HTML source code via this viewhelper in your copy of EXT:powermail/Resources/Private/Templates/Form/Form.html

{namespace pc=In2code\PowermailCond\ViewHelpers}
<script type="application/json" id="form-{form.uid}-actions">{pc:conditions(form:form) -> f:format.raw()}</script>
<style type="text/css">
    .powermail_fieldset {
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.5s, visibility 0.5s;
    }
</style>

This way the initial asynchronous call will be skipped which reduces the flickering to a minimum.

Early Access Programm for TYPO3 13 support

ℹ️ TYPO3 13 compatibility

See EAP page (DE) or EAP page (EN) for more information how to get access to a TYPO3 13 version

Changelog

More to come soon?

  • Use vanilla JS instead of jQuery

Conflicts

  • It's not possible to use powermail multistep forms with powermail_cond