Issue Bug Under Review

#111338Stop persisting records in invalid states due to force reload and persist

Benjamin Kott 11/04/26, 11:20 updated 11/20/26, 20:22

Description

Problem

When an editor changes the type field of a record (for instance CType of a content element or doktype of a page), or any field configured with 'onChange' => 'reload', FormEngine asks for confirmation, suspends its validation and saves the whole record, then loads the edit form again. The record is written in whatever state the form holds at that moment:

  • a new record is created with required fields still empty,
  • an existing record is saved with invalid or half-entered values,
  • DataHandler hooks and events run for a save the editor never asked for,
  • declining the confirmation leaves the form showing the fields of the old type.

Related reports: #36660 (required fields bypassed on type switch), #91089 (forced reload with save when editing several records), #96992 (whole record reloads after a change in a nested inline record), #107888 (record saved with an empty required field after unchecking all options of an onChange field).

Steps to reproduce

  1. Create a new content element of type “Text” and leave its header empty while the header is required for another type
  2. Change the field “Type” (CType) to another type and confirm the dialog
  3. See that the record is saved to the database without validation, with empty required fields

Cause

The reload of FormEngine (FormEngine.requestFormEngineUpdate() and ReloadOnFieldChange) has no way to render the form for new values other than saving the record through EditDocumentController and DataHandler: it calls Validation.suspend() and submits the form.

Reviews 1

History 476

Show 051 earlier messages
  1. Gerrit Code Review pushed patch set 28 for main to change 97304 status New Under Review <span data-processor="relativetime" data-value="2026-11-04T11:21:56+00:00" > 11/04/26, 11:21 </span>