You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a model with a BelongsToMany relationship. It has a standard Filament resource with pages.
The form of this resources includes a Select field where multiple records can be selected for a BelongsToMany relationship. This all works fine on the Edit page, but on the Create page, no relations are created in the pivot table.
The strange thing is that if the field has validation, the validation does work! After that however, the $state is always null and the data is not saved.
Again: Everything works on the Edit page, just not on the Create page.`
Expected behavior
When I create a new record (book in my example) and select two authors in the 'author' Select field, I expect the book to be created, with the two authors linked via the author_books table.
Instead, the author_books table is not touched and the authors field is empty after the page redirects to the Edit page for the newly created book.
Sidenote: Idk whether this is actually a bug or just a mistake by me. Regardless, I donated via Polar even if it's just a small thank you for the business value that Filament has already provided to my product.
It looks like the select multiple field also gives problems when not using a relationship and just saving an array to a json field... It works on edit page but not on create; the state is always null when the create form is dehydrated.
Package
filament/forms
Package Version
v3.2.121
Laravel Version
v11.9
Livewire Version
No response
PHP Version
PHP 8.3
Problem description
I have a model with a
BelongsToMany
relationship. It has a standard Filament resource with pages.The form of this resources includes a
Select
field where multiple records can be selected for aBelongsToMany
relationship. This all works fine on the Edit page, but on the Create page, no relations are created in the pivot table.The strange thing is that if the field has validation, the validation does work! After that however, the
$state
is alwaysnull
and the data is not saved.Again: Everything works on the Edit page, just not on the Create page.`
Expected behavior
When I create a new record (book in my example) and select two authors in the 'author'
Select
field, I expect the book to be created, with the two authors linked via theauthor_books
table.Instead, the
author_books
table is not touched and theauthors
field is empty after the page redirects to theEdit
page for the newly created book.Steps to reproduce
composer install; php artisan migrate; php artisan db:seed;
(sorry if I missed anything)Reproduction repository (issue will be closed if this is not valid)
https://github.com/caswd/replicate-filament-create-with-many-to-many-select-issue
Relevant log output
No response
Donate 💰 to fund this issue
The text was updated successfully, but these errors were encountered: