Review main Merged

90144[BUGFIX] Allow form element identifier in email finisher overrides

Josua Vogel CR +2 V +2 Normal +65 −8 updated 09/19/25, 12:02

Commit message

When using the EXT:form plugin as a content element, it's flexform
definition allows to override certain elements of the form config.

For example, the "Email to sender" finisher allows to specify
an email address, which FormEngine renders as "type: email". Thus,
this only allows to enter valid emails.

However, one main reason to use flexform overrides for the plugin is
to be able to insert form element references so that the "Email
to sender" plugin actually uses the input of a frontend form
to send the mail to, by inserting `{userMailto}` or something else
as the identifier.

Doing so prevented FormEngine validation to save the input because
it no longer matched an email.

Sadly, the "type: email" attribute is tightly bound to the EXT:form
backend GUI. If just set to "type: input" then the input of the backend
would no longer enforce only entering valid emails. EXT:form extracts
the flexform settings from the base YAML with a complex method
to provide editing a plugin instance's specific mail addresses
within FormEngine.

So a solution was needed that allowed to:

1) Require to enter only valid emails in EXT:form GUI
2) Allow to enter either a valid email in FormEngine flexform
overrides, or a `{...}` identifier reference.

This is now solved with a custom formeval implementing a check
for both syntaxes, and not storing invalid values.

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
    • Christian Kuhn +1
  • Verified V +2 Done
    • Garvin Hicking +2
    • Christian Kuhn +1
    • core-ci +1 CI

Issues 1

Files 4

Review log 3447

Show 1622 earlier messages
  1. Josua Vogel uploaded patch set 1 07/24/25, 14:21

  2. core-ci voted on patch set 1 V -1 07/24/25, 14:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82249

  3. Josua Vogel uploaded patch set 2 V -1 07/24/25, 14:39

  4. core-ci voted on patch set 2 V +1 07/24/25, 14:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82252

  5. Garvin Hicking updated the commit message in patch set 3 V +1 07/28/25, 09:12

  6. Garvin Hicking commented on patch set 3 07/28/25, 09:12

    I didn't find out what "SW" is referring to, maybe we can find a more speaking name for this?

    DataHandlerHook.php:54

    I think we can do this without a temporary variable and legibility doesn't suffer too much? ```suggestion if (!GeneralUtility::validEmail($res['value']) && !preg_match('/\{.+\}/', $res['value'])) { ```
  7. core-ci voted on patch set 3 V +1 07/28/25, 09:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82420

  8. Josua Vogel commented on patch set 3 07/28/25, 09:21

    Reply

    Yes, I wanted to name it after the method in which the hook was called. Perhaps SW stands for switch (because different methods are called for the TCA types). I will adjust it.

    DataHandlerHook.php:54 Reply

    I like short conditions from a clean code perspective and for readability. Do you see any disadvantage to using a temporary variable?
  9. Garvin Hicking commented on patch set 3 07/28/25, 09:55

    Notes from our private chat: - Will be applied to all "type:email" inputs of the YAML - Also apply to `settings.finishers.EmailToSender.senderAddress`? - Hook needs to evaluate `$additionalData['flexFormPath']` in case `$field` is empty

    DataHandlerHook.php:54 Reply

    I wouldn't press on it, I don't think we have a hard "rule" on this in the TYPO3 core. If you feel more comfortable with it, it's your contribution, I'm good with it :-)
  10. Josua Vogel uploaded patch set 4 V +1 07/28/25, 14:18

  11. Josua Vogel updated the commit message in patch set 5 07/28/25, 14:18

  12. core-ci voted on patch set 4 V +1 07/28/25, 14:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82426

  13. core-ci voted on patch set 5 V +1 07/28/25, 14:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82427

  14. Garvin Hicking updated the commit message in patch set 6 V +1 07/28/25, 14:41

  15. Garvin Hicking commented on patch set 6 CR +1 V +1 07/28/25, 14:42

    Reply

    Done
    Thanks, this is a nice tradeoff to me! :-)

    Reply

    works for me :)
  16. core-ci voted on patch set 6 V +1 07/28/25, 14:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82429

  17. Oli Bartsch commented on patch set 6 V -1 07/28/25, 14:55

    Hi thanks for your patch. I unfortunately think that we can not move on with the current approach. Please have a look at my comments. I still suggest to use dedicated new @internal option on type "input" to add both client and server-side validation.

    DataHandler.php:1322

    A new hook / event always needs documentation. However, I don't think that we should introduce new hooks at this place at all.

    DataHandlerHook.php:30

    I think we need some client side validation as well.

    DataHandlerHook.php:47

    `renderType` are for display purposes only and are not to be evaluated by the Datahandler.
  18. Josua Vogel commented on patch set 6 07/28/25, 15:07

    Reply

    Do you mean adding a custom type that´s only internal?

    DataHandler.php:1322 Reply

    Understand this. This hook would give the ability to have a real serverside validation and prevent saving a record. I looked at SourceHost (inside EXT:redirects) - the serverside evaluation just clears the value, but the record is saved anyways. IMO that behaviour isn´t great and there is no good alternative. This hook could be used by custom fields like SourceHost to prevent the saving of an invalid record without manipulation magic

    DataHandlerHook.php:30 Reply

    totally agree
  19. Josua Vogel commented on patch set 6 07/28/25, 15:12

    DataHandlerHook.php:47 Reply

    Okay. Theoretically, you could render the field differently and display a dropdown for the FormElementIdentifier in the long term, as in FormEditor.
  20. Garvin Hicking commented on patch set 6 CR 0 V 0 07/28/25, 15:29

    Thanks Oli for the additional thoughts. I hope we can find a way to solve this.
  21. Oli Bartsch commented on patch set 6 07/28/25, 15:37

    Reply

    No need for a new type IMO. We should just need a new TCA config option for type=input.

    DataHandler.php:1322 Reply

    Would like to have an opinion from @lolli@schwarzbu.ch here.

    DataHandlerHook.php:47 Reply

    Sure that's what a renderType is for. I just want to ensure we do evaluate it in DH context. We did this previously already and then migrated all those usages to dedicated tca types instead.
  22. Josua Vogel commented on patch set 6 07/28/25, 15:49

    Reply

    Okay, that´s possible. The only drawback would be, that the new config option isn´t located inside EXT:form, instead we extend the type in EXT:backend. Or do I miss an option to define a new config option for an existing TCA type inside another extension?
  1. Oli Bartsch commented on patch set 6 07/28/25, 16:22

    Reply

    Adding an option basically means it is evaluated somewhere. So the place where it is evaluated matters. But, I could think of a new `renderType` resulting in a dedicated Element class which then checks tor this option to add custom client side logic. Additionally we then need to evaluate this option (independent of the renderType) in the DH. I'm ad-hoc not quite sure if this is completely possible via hooks. That's why I cc'ed Christian.
  2. Josua Vogel updated the commit message in patch set 7 V +1 07/28/25, 16:53

  3. core-ci voted on patch set 7 V +1 07/28/25, 17:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82441

  4. Garvin Hicking updated the commit message in patch set 8 V +1 07/30/25, 15:32

  5. core-ci voted on patch set 8 V +1 07/30/25, 15:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82556

  6. Josua Vogel commented on patch set 8 08/13/25, 19:31

    DataHandler.php:1322 Reply

    hi @lolli@schwarzbu.ch what’s your opinion on this?
  7. Christian Kuhn commented on patch set 8 08/22/25, 14:57

    thanks for the patch. i'm aware not being able to use placeholders in the flex overrides is an issue. the patch is a bit intrusive, though, and i wonder if we couldn't 'fix' this differently: first, i'm neither a fan of the new DH hook (we shouldn't add more hooks they give additional headaches, we should fix the server side validation issue when DH has been refactored to support this is a good way, instead). furthermore, extending InputElement is fishy, those classes should be final and shouldn't be extendable. what do you think about fixing the issue more straight forward? We simply switch from type-email to type-input and stop validating email-adresses at this point. this gives freedom to use placeholders, with the drawback of not giving editor feedback in case they don't submit valid emails anymore. I think that would be acceptable considering the headaches with the given solution?! We could then see if we could validate the given data after placeholder substitution happened (if that is not the case already?), maybe when the form is rendered or a form is sent, or maybe as a note after sending using the additional 'information' API of FormEngine or something like that? This would release us from messing around with DH at this point and could lead to an acceptable solution as well? Do you think it is worth looking into something like that? On a different note: I think the 'dynamic' creation of flex form stuff in ext:form is flawed in the first place, not only codewise, but also strategically, but I'm also unsure on how to change this in a good way. And that is only *one* problem with ext:form ... As such, I'm very happy Josua is pushing patches in various areas of the module and I hope further people review the changes.
  8. Josua Vogel uploaded patch set 9 V +1 09/04/25, 15:05

  9. Josua Vogel uploaded patch set 10 09/04/25, 15:05

  10. Josua Vogel uploaded patch set 11 09/04/25, 15:06

  11. Josua Vogel commented on patch set 11 09/04/25, 15:09

    The bug fix has been updated so that it resolves the issue without interfering too deeply. Unfortunately, JavaScript validation is not possible. The custom eval function can only be used to manipulate values, but not to trigger validation errors. In my opinion, a universal solution should be created, but not via this bug fix.
  12. Josua Vogel commented on patch set 11 09/04/25, 15:10

    Reply

    Done

    DataHandler.php:1322 Reply

    Done

    DataHandlerHook.php:30 Reply

    Done

    DataHandlerHook.php:47 Reply

    Done
  13. core-ci voted on patch set 9 V -1 09/04/25, 15:14 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/84386

  14. core-ci voted on patch set 10 V -1 09/04/25, 15:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/84387

  15. core-ci voted on patch set 11 V +1 09/04/25, 15:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/84388

  16. Garvin Hicking commented on patch set 11 09/04/25, 16:36

    EmailOrFormElementIdentifier.php:23

    ```suggestion * Triggered from DataHandler as TCA formevals hook for validation / sanitization of domain values. ```

    EmailOrFormElementIdentifier.php:30

    ```suggestion * Server-side removing of invalid email value on save ```

    EmailOrFormElementIdentifier.php:38

    ```suggestion if (!$isValidEmail && !preg_match('/^\{[^\}]+\}$/', $value)) { ``` Maybe anchoring start/end is useful here? Input like "{email1-id},{receiver}" or so is not valid, right?

    EmailToSender.yaml:60

    This wasn't type:email before, so could people enter something like '"user" <some@example.com>"' and allow it to be passed?
  17. Josua Vogel commented on patch set 12 V +1 09/04/25, 16:56

    Published edit on patch set 11.
  18. Josua Vogel commented on patch set 12 09/04/25, 16:56

    EmailOrFormElementIdentifier.php:23 Reply

    Fix applied.

    EmailOrFormElementIdentifier.php:30 Reply

    Fix applied.

    EmailOrFormElementIdentifier.php:38 Reply

    Fix applied.

    EmailToSender.yaml:60 Reply

    no, sender name is an extra field. this is just an inconsistency
  19. core-ci voted on patch set 12 V +1 09/04/25, 17:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/84392

  20. Garvin Hicking commented on patch set 12 CR +1 V +1 09/06/25, 20:44

    I think this is improving the situation. Waiting for @lolli@schwarzbu.ch however, please.
  21. Garvin Hicking updated the commit message in patch set 13 CR +1 V +1 09/19/25, 10:52

  22. core-ci voted on patch set 13 V +1 09/19/25, 10:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85162

  23. Christian Kuhn commented on patch set 13 CR +1 V +1 09/19/25, 11:47

    garvin and me looked at this for quite a while now - the solution is not optimal when persisting the record. but it's better than before. we'll follow this path for now and may improve client side with another patch.
  24. Garvin Hicking voted on patch set 13 CR +2 V +2 09/19/25, 11:48

  25. Garvin Hicking merged patch set 14 09/19/25, 12:02