Package
filament/filament
Package Version
v5.x
Laravel Version
v12+
Livewire Version
v4
PHP Version
PHP 8.4
Problem description
Select with ->relationship handling doesn't work as I would expect.
In my resource I have the following:
`
Select::make('partner_parent_id')
->relationship(name: 'parent', titleAttribute: 'name')
->label('Partner padre')
->preload()
->searchable()
->loadingMessage('Caricamento partner...'),
`
The "parent" relationship is a one-to-one relationship with the same table.
The scenario is the following: I need to create entities that may have a parent-child relationship. An entity may have 0 or 1 parent. I create the first entity without assigning a parent to it as there are none. Then, I create another entity and set the previously created entity as this one's parent.
The new entity is created correctly, however it also becomes its parent's parent.
Expected behavior
I would expect that the parent's entity 'parent_id' remains unset.
Steps to reproduce
- Create Filament user
- Go to /admin panel
- Log in and create a new "Partner" from "Partner resource" (insert name only)
- Create another "Partner" and set the 'partner_parent_id' field, labeled 'Partner padre' to the previously created entity
- After creation, you will see that the previously created entity's parent is set to the newly created entity's id
Reproduction repository (issue will be closed if this is not valid)
https://github.com/FrancescoTerrosi/select-relationship-bug
Relevant log output
Package
filament/filament
Package Version
v5.x
Laravel Version
v12+
Livewire Version
v4
PHP Version
PHP 8.4
Problem description
Select with ->relationship handling doesn't work as I would expect.
In my resource I have the following:
`
`
The "parent" relationship is a one-to-one relationship with the same table.
The scenario is the following: I need to create entities that may have a parent-child relationship. An entity may have 0 or 1 parent. I create the first entity without assigning a parent to it as there are none. Then, I create another entity and set the previously created entity as this one's parent.
The new entity is created correctly, however it also becomes its parent's parent.
Expected behavior
I would expect that the parent's entity 'parent_id' remains unset.
Steps to reproduce
Reproduction repository (issue will be closed if this is not valid)
https://github.com/FrancescoTerrosi/select-relationship-bug
Relevant log output