Skip to content

Nested relationships not working #17407

@stian-scholtz-snappi

Description

@stian-scholtz-snappi

Package

filament/filament

Package Version

v4.0.0

Laravel Version

v12.0.0

Livewire Version

No response

PHP Version

8.4

Problem description

When attempting to save nested relationships, for example, Order->DeliveryAddress->Contact you either get validation errors on the Contact's inputs, if you mutate the data for validation then the data does not get inserted for Contact.

Expected behavior

In General I am trying to achieve a form for OrderResource and on the form I am attempting to create an Order, DeliveryAddress (belongsTo relation on Order), and a Contact (belongsTo relation on Address). So in other words I want to be able to nested relationship on a single form.

Steps to reproduce

Create a resource with a form that looks something like this:

class OrderForm { public static function configure(Schema $schema): Schema { return $schema ->components([ TextInput::make('order_number')->required(), Fieldset::make('Delivery Address') ->relationship('deliveryAddress') ->columnSpanFull() ->schema([ TextInput::make('street_address') ->columnSpanFull() ->required(), Group::make([ TextInput::make('name') ->label('Contact Name') ->required() ])->relationship('contact') ]) ]); } }

Reproduction repository (issue will be closed if this is not valid)

https://github.com/stian-scholtz-snappi/filament_nested_relation_demo

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions