Problem saving records in Repeater with a relationship

I have setup a repeater with a relationship in a relation manager and the records in the repeater are not saving properly. The fields from the repeater schema are not being included in the query to persist the record to the database. My model relationship structure: Hill Chart has many Scopes and has many Snapshots Scopes belong to a Hill Chart and has many Positions Snapshots belong to a Hill Chart and has many Positions Positions belong to a Snapshot and belong to a Scope In my HillChartResource, I have a ScopesRelationManager and a SnapshotsRelationManager. The ScopesRelationManager is working perfectly. The issue is in the SnapshotsRelationManager. In it, I have a repeater with a relationship to Position with three fields. One of the fields is a Select with a relationship to Scopes. When I attempt to saving the Snapshot, it correctly creates the Snapshot record in the database and attempts to create the first Position record. That SQL query throw an error: SQLSTATE[HY000]: General error: 1364 Field 'scope_id' doesn't have a default value
insert into `positions` (`snapshot_id`, `updated_at`, `created_at`) values (10, 2023-12-23 02:17:50, 2023-12-23 02:17:50)
insert into `positions` (`snapshot_id`, `updated_at`, `created_at`) values (10, 2023-12-23 02:17:50, 2023-12-23 02:17:50)
The SQL should also include the three fields from the repeater: scope_id, x, and y. I have manually added data to the database to check whether editing works. The repeater is working enough to correctly load the data for all the positions associated with the snapshot, but the saving edits does not work because the fields are not included in the update. (No error thrown since excluding those three fields is still valid SQL. Here is the relevant code: https://gist.github.com/jpangborn/f46064f1d6663c89ff34a83837e439f5 I have seen online that others have had similar problems, but for most of them started working without understanding why.
Gist
gist:f46064f1d6663c89ff34a83837e439f5
GitHub Gist: instantly share code, notes, and snippets.
0 Replies
No replies yetBe the first to reply to this messageJoin