Ash FrameworkAF
Ash Framework2mo ago
10 replies
Yahya Oxley

Managing sibling cross-references in nested forms

Hi everyone, I have a Project with two nested relationships:
tasks (has_many)
team_members (has_many) each member has assignments which reference a task

Project
  ├── Task (id: "temp-0" until saved)
  └── TeamMember
        └── Assignment (needs task_id FK)


When I add a new task in the form (before saving), I want to assign team members to that task via Assignment. But the task doesn't have a real ID yet, just a temp client-side one. At save time, manage_relationship creates the tasks first, but the assignment params still have the temp ID, so the FK can't resolve. Is there a standard Ash pattern for this? I've considered referencing by name instead of ID, or using embedded resources, but wondering if there's something built-in I'm missing.
Was this page helpful?