Aurora.Uix.Templates.Basic.Renderers.OneToOne (Aurora UIX v0.1.5)

Copy Markdown

Renders one-to-one (has_one) association fields as an inline nested form or group.

A has_one matches neither of the other association renderers: the foreign key lives on the remote side (like has_many) while the cardinality is 1 (like belongs_to). There is no local column for a <select> to bind to, and a sub-index table with an "add another" action would contradict the cardinality. The shape used here is therefore the one Aurora.Uix.Templates.Basic.Renderers.EmbedsOneRenderer builds: nested inputs that submit in the same POST as the parent.

Key Features

  • :form renders the child's :form layout inline through <.inputs_for>, so the child is created or updated in the same request as the parent.
  • Nested inputs are always present, even when no child record exists yet.
  • :show renders the child's :show layout as a read-only group, or an empty-field message when there is no child.
  • The child's foreign key back-reference is suppressed, so the parent is not offered as a redundant selector inside its own nested form.
  • Renders nothing when the related schema is not a registered Aurora UIX resource.

Key Constraints

  • The library is transport-only for writes: it renders nested input names and forwards params untouched, and never builds a changeset. Persisting the child is the host's responsibility — cast_assoc/3 in an Ecto changeset, or argument + change manage_relationship(...) in an Ash action.
  • An Ash host whose action declares no matching argument + manage_relationship raises AshPhoenix.Form.NoFormConfigured. This is deliberate — swallowing it would make the misconfiguration invisible until data silently failed to persist.
  • A submission where every nested input is blank is forwarded unchanged. Whether that means "skip the child" or "invalid" is decided by the host's changeset or action, not here.
  • Requires the related resource to be registered and its :form / :show layout resolvable; otherwise no nested elements render.
  • The parent must be preloaded for :show and for editing a persisted record. filter_preloads/1 handles this; a missing preload surfaces as an unloaded association, not as rendered inputs.

Summary

Functions

Renders a one-to-one association field.

Functions

render(assigns)

@spec render(map()) :: Phoenix.LiveView.Rendered.t()

Renders a one-to-one association field.

Parameters

  • assigns (map()) - LiveView assigns containing:
    • :field (map()) - Field configuration with association details in :data.
    • :auix (map()) - Aurora UIX context with form, entity and layout configuration.

Returns

Phoenix.LiveView.Rendered.t() - Rendered one-to-one association component.