mautic / mautic-typo3

Add-on TYPO3 extension that enhances the "EXT:marketing_automation" TYPO3 extension by connecting it to the Mautic Marketing Automation platform: Determine "Persona" from Mautic segments. Also provides additional services e.g. language synchronisation between Mautic and TYPO3.
https://www.Leuchtfeuer.com
GNU General Public License v2.0
22 stars 19 forks source link

FormFinisher "Send to Mautic Form" creates multiple form-fields on Mautic side if an existing form is edited #85

Closed Moongazer closed 10 months ago

Moongazer commented 10 months ago

When a new Mautic form is created in TYPO3 backend using the FormFramework and the FormFinisher "Send to Mautic Form", the first saving action creates the form with all it fields also on the Mautic side. The form config looks like the following (shorted):

        renderables:
          -
            properties:
              mauticTable: firstname
              mauticId: 36
              mauticAlias: text_1
            defaultValue: ''
            type: Text
            identifier: text-1
            label: Firstname

As we can see, TYPO3 saves the attributes mauticId and mauticAlias returned from Mautic with values of the newly created fields.

If we edit this form in TYPO3, for example to add a new field, the saving action successfully creating this field on the Mautic side, BUT TYPO3 does not receive or save the attributes mauticId and mauticAlias of that new field to the form config!

        renderables:
          -
            properties:
              mauticTable: firstname
              mauticId: 36
              mauticAlias: text_1
            defaultValue: ''
            type: Text
            identifier: text-1
            label: Firstname
          -
            properties:
              mauticTable: lastname
            defaultValue: ''
            type: Text
            identifier: text-2
            label: Lastname

What happens now if we edit the form a 3rd or 4th time is, that the field for "lastname" is created again and again on Mautic side, basically filling the form in Mautic with multiple (identical) fields on every saving action.

Expected behavior When editing an existing form, new fields must saved with their related mauticId and mauticAlias.

Environment Server: DDEV / Nginx TYPO3: 10.4.37 EXT:mautic: 4.1 PHP: 7.4 (The issue also exists in the version for TYPO3 v11 with EXT:mautic 4.4)

Edit 1: Found this line in code https://github.com/mautic/mautic-typo3/blob/004d39c6181970a473231ce004842b8b0e043670/Classes/Transformation/FormField/AbstractFormFieldTransformation.php#L71 but not sure if this was implemented already somewhere else (because it mentions exactly the missing attributes), nor why it should be like this.