Issue Task Resolved

#111226Resolve relations of FlexForm sheet fields in FlexFormSchemaFactory

Benni Mack 10/24/26, 11:12 updated 10/25/26, 01:35

Description

FlexFormSchemaFactory turns the fields of a resolved FlexForm data structure into Schema API field types. Several things make the result unusable for code that works on database rows, such as the DataHandler:

  • The only entry point, getSchemaForRecord(), requires a RawRecord. DataHandler and most other consumers have plain rows.
  • Relational sheet fields (group, select with foreign_table, inline,
    file, category) have no relations: the only caller passes an empty
    RelationMap, so getRelations() returns nothing and
    ActiveRelation::isManyToMany() / manyToManyTable() / toField()
    cannot be used. With a populated map, every sheet field would
    receive the relations of all fields of the same flex column, as
    the lookup is not scoped to the field.
  • A sheet field of an unknown type throws FieldTypeNotAvailableException, so the whole schema cannot be built.
  • Only some data structure exceptions are caught, so an InvalidDataStructureException escapes, while DataHandler catches AbstractInvalidDataStructureException.

Solution:

  • Add getSchemaForRow(string $tableName, FlexFormFieldType $field, array $row); getSchemaForRecord() delegates to it.
  • Build the relations of each sheet field from its own configuration. Nothing can point to a field within a data structure, so no global RelationMap is needed; the RelationMap argument of getSchemaForRecord() becomes optional and is no longer evaluated.
  • Skip sheet fields of unavailable types.
  • Return null for every AbstractInvalidDataStructureException.

This is the groundwork for using Schema API field objects instead of raw data structure arrays for FlexForm fields in the DataHandler.

Reviews 4

History 12

  1. Benni Mack commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-10-25T01:35:13+00:00" > 10/25/26, 01:35 </span>

    Applied in changeset commit:3dae943cbb53eb7957aac87b9fb9f8e52ba25b60.