Review main Abandoned

96122[WIP][TASK] Restore FormEngine values after a rejected save

Benni Mack CR 0 V 0 Hard +660 −0 updated 10/18/26, 06:59

Commit message

If DataHandler rejects a record outside of TCA validation, e.g. via
a processDatamap_preProcessFieldArray hook or an event listener
(this is how EXT:scheduler validates task parameters), FormEngine's
redirect used to show the previous, unrelated database values again
and the submitted input was lost.

The submitted values of a rejected record are now kept in the
backend user's session for one redirect and restored once the
record is re-opened. Only plain scalar fields are restored; flex
form and relational fields keep the persisted value.

Review

  • Code review CR 0
  • Verified V 0
    • core-ci +1 CI

Issues 1

Files 8

Review log 56

  1. Benni Mack uploaded patch set 1 09/28/26, 10:02

  2. core-ci voted on patch set 1 V +1 09/28/26, 10:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/109405

  3. Garvin Hicking commented on patch set 1 09/28/26, 14:36

    DatabaseRowRestoreOnValidationFailure.php:37 Unresolved

    I would skip "password" here to prevent echoing back passwords in plaintext for the editform.
  4. Daniel Windloff commented on patch set 1 10/04/26, 09:46

    Hey Benni, I consider the fact that user input is discarded upon validation errors to be a significant missing mechanism. I do not really like the implementation approach of storing data in the session, as this introduces an additional persistence cource for the data and therefore would be hard to test and debug. I would prefer an approach like the one sketched up as follwing: - After processing via the DataHandler, collect all unprocessed entries. The error log serves as the source for edits, while the list of unresolved "NEW" placeholders serves as the source for new records. - Map these records to the `editconf` identifier, resulting in an array structure like `$invalidValues[tablename][<editconf>][column] = value`. New uids related to auto created workspace versions of the record might be resolved as well, as the creation could happen before the validation error. - Add a method to TcaSchema for each field type to determine whether values ​​should be hold in the event of an error. - Remove any disallowed columns (such as plaintext passwords) from `$invalidValues` based on this configuration from TcaSchema. - Force a redirect and pass these $invalidValues values ​​as redirect parameters, so that the user stay in the edit view. - In `EditDocumentController`, process the parameter and pass it to FormEngine for each `editconf`, analogous to `$formDataCompilerInput['overrideValues']`. Filter again for not handled values based on TcaSchema configuration before. - A DataProvider, similar to `DatabaseRecordOverrideValues`, takes these values ​​and overrides them. - Process a flag, that marked related columns to inform the user about validation issues - Now the user can correct the false values and save again. Potential issues, I would expect: - FlexForms would likely remain unsupported without significant additional logic. - For many new created entries at once, the mapping between NEW-Identifiers and editconf could be unstable. - Errors related to relations such as min/max-items are not resolved properly, as the DataHandler still writes records, but the editing could be cancelled. - Some persistence like sorting, language, new created versions could be already happend. What do you think?
  5. Benni Mack commented on patch set 1 10/18/26, 06:59

    Reply Unresolved

    Hey Daniel, this was a first attempt, because I don't know the best approach. The main issue that core never had a good solution for handling validation, and this now bites us because Scheduler is using DataHandler + FormEngine as well. I personally think that _if_ we attempt to rework DataHandler, that we should consider this problem, not really this solution. See the forge ticket for more details on the issue. I only wanted to show-case one use-case for the ticket author, but I wasn't able to spend too much time on this issue (that's why it was WIP). I will abandon it, because I think Garvin has a better solution.
  6. Benni Mack abandoned the change 10/18/26, 06:59

    abandoned.