Aurora.Uix.Templates.Basic.EmbedsManyComponent (Aurora UIX v0.1.4-rc.4)

Copy Markdown

A LiveComponent for managing embeds_many associations in Aurora.Uix forms.

This component provides a complete interface for displaying, adding, and managing embedded records within a parent form. It handles the rendering of existing embedded entries, modal dialogs for adding new entries, and integrates with Aurora.Uix's action system for custom operations.

Required Assigns

  • :auix - Aurora.Uix context containing form state, layout configuration, and resource definitions
  • :field - Field definition map with :data containing :resource name for the embedded schema

Layout Requirements

The component expects :layout_type to be :form and requires layout configuration for the embedded resource to be available in the Aurora.Uix context.

Example

<.live_component
  module={Aurora.Uix.Templates.Basic.EmbedsManyComponent}
  id="user-addresses"
  auix={@auix}
  field={%{
    key: :addresses,
    html_id: "user_addresses",
    data: %{resource: :address}
  }}
/>

Summary

Functions

Validates the form for adding a new embedded entry.

Renders the embeds_many component interface.

Functions

handle_event(binary, params, socket)

@spec handle_event(String.t(), map(), Phoenix.LiveView.Socket.t()) ::
  {:noreply, Phoenix.LiveView.Socket.t()}

Validates the form for adding a new embedded entry.

This handler is triggered on form change events within the add entry modal. Currently performs no validation logic but is required for the form's phx-change binding.

Parameters

  • event (String.t()) - The event name (always "validate")
  • params (map()) - Form parameters (unused)
  • socket (Phoenix.LiveView.Socket.t()) - The current socket

Returns

{:noreply, Phoenix.LiveView.Socket.t()} with unchanged socket state.

render(assigns)

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

Renders the embeds_many component interface.

Displays existing embedded entries with their configured actions, and provides either a modal for adding new entries (when enabled) or footer actions. The layout is determined by the embedded resource's form configuration.

Parameters

  • assigns (map()) - Component assigns containing:
    • :auix (map()) - Aurora.Uix context with :layout_type set to :form or :show.
    • :field (map()) - Field definition with :data map containing :resource atom identifying the embedded schema

Returns

A rendered Phoenix.LiveView.Rendered struct with the complete embeds_many interface.