Zum Inhalt springen

Serialnumber for TYPO3 System Extension Form

Add to the messages from your users a unique number with the TYPO3 add-on Extension „form_serialnumber“

The extension „form_serialnumber“ depends on the TYPO3 system extension „EXT:form“ and a TYPO3 installation 9.5.x (as for today 2019 February).

What does it do?

  • it gives you an additional finisher for your forms
  • it gives you a variable {Serialnumber.serialnumber} that holds the serialnumber that you can use e.g. in your email responses
  • it has an identifier, so you can use different counters for different forms, or the same counter for different forms (Let’s say you have a quick reply form and a long reply form, so for both you can use the same counter and it will give you a serialnumber for both forms, counting upwards with every post of an entry of either form)
  • it has a field for a prefix (e.g. „2019-xxxxxx“)
  • it allows you to add a field on your email that goes to you after submit


Where to get it?

https://bitbucket.org/t–3/form_serialnumber/src

And of course inside your TYPO3 system.

Developer is Armin Vieweg who we all know from the „DCE-Extension“. The remitter is Thomas Hezel from zazu.berlin

How to setup your own form with Ext:form, Ext:serialnumber_form and YAML-Language for making the settings

Here we assume that you still work the „old“ way, having your stuff in the fileadmin and not in a sitepackage extension (a unique extension with all code for this only website).

First you need a new folder „Yaml“ in fileadmin. Best pracitice is to have it in: fileadmin/Configuration/Yaml

Ext:form is putting later a folder directly in fileadmin with the name „form_definitions“, that is hosting YAML-form-definitions. Basically it is the information how your form looks like. This file can later move to a new TYPO3 website for reuse.

In our new fileadmin/Configuration/Yaml folder we can now put a text file with the name myFormSetup.yaml

TYPO3:
  CMS:
    Form:
      prototypes:
        standard:
          formElementsDefinition:
            Form:
              renderingOptions:
                templateRootPaths:
                  100: 'fileadmin/Resources/Private/Templates/FormTemplates/'
                partialRootPaths:
                  100: 'fileadmin/Resources/Private/Partials/FormPartials/'
                layoutRootPaths:
                  100: 'fileadmin/Resources/Private/Layouts/FormLayouts/'

The code tells your form that it has to look for the form templates, partials and layouts in the folders you specify. Use always a number from 100 upwards.

After this you can copy from the folders typo3/sysext/form/Resources/Private/… all template files in your new destination to change css classes and adjust the output of the form templates to your need. But keep the original structure inside your folders, as it was in sysext!

To tell form, that it should use the new (modified by your needs) templates and partials you need some TypoScript in your basic TypoScript-setup:

plugin.tx_form {
    settings {
        yamlConfigurations {
            100 = fileadmin/Configuration/Yaml/myFormSetup.yaml
        }
    }
}

Now you got to the left side of your TYPO3 backend and use the form module to create your form. To integrate your serialnumber just choose your serialnumber finisher. How to do this you find propper instructions from Armin Vieweg in the manual of the Ext:serialnumber_form.

Use your own template for the way form is giving the user a confirmation

Unfortunately the confirmation message of form (if you use this finisher) is just plain text, without any HTML tags arround. And, if you look in the form templates and partials you will not find any confirmation finisher.

I tried to make may own YAML-configuration to guide Ext:form to a confirmation finisher in the way we did it with the other files, but it didn’t work. What worked was the following shortcut:

Open – inside the fileadmin/form_definitions folder – the YAML-file that represents your form. Add here, in the confirmation section, the location and name of your „confirmation-template“ -> templateName and templateRootPaths

 -
    options:
      message: 'STÖRUNG GEMELDET!'
      contentElementUid: ''
      templateName: Confirmation.html
      templateRootPaths:
        20: fileadmin/Resources/Private/Templates/FormTemplates/Finishers/Confirmation/
    identifier: Confirmation
  -

My Template for the „Confirmation.html“ looks like this:

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:formvh="http://typo3.org/ns/TYPO3/CMS/Form/ViewHelpers" data-namespace-typo3-fluid="true">

<div id="gemeldetBtn">{message}</div>
</html>

Whereat {message} gives you the variable content of the confirmation message.

Autor: Thomas Hezel

Abbonieren Sie diesen Blog

Sei der Erste der einen Kommentar abgibt

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Ich akzeptiere

*

code