Skip to content
\n

Default data
\n\"image\"

\n

Change to income before saving, the recipient and paid off date is automatically null
\n\"image\"

\n

After saving the changes the recipient is filled with the previous recipient with the field is disabled
\n\"image\"

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

The issue stems from relationship hydration taking precedence after save. Add afterStateHydrated to force null state: ->afterStateHydrated(function ($state, $set, $get) { if ($get('type') === TransactionType::income->value) { $set('recipient_id', null); } }). Alternatively, use ->saveRelationshipsUsing(fn($get) => $get('type') === TransactionType::income->value ? null : function() {}) as suggested in issue #17778. This is an open issue in Filament v4.

","upvoteCount":1,"url":"https://github.com/filamentphp/filament/discussions/18668#discussioncomment-15200919"}}}
Discussion options

You must be logged in to vote

The issue stems from relationship hydration taking precedence after save. Add afterStateHydrated to force null state: ->afterStateHydrated(function ($state, $set, $get) { if ($get('type') === TransactionType::income->value) { $set('recipient_id', null); } }). Alternatively, use ->saveRelationshipsUsing(fn($get) => $get('type') === TransactionType::income->value ? null : function() {}) as suggested in issue #17778. This is an open issue in Filament v4.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@oktavianoandy
Comment options

Answer selected by oktavianoandy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants