Select relationship value not retained after saving
brianakidd opened this issue · 5 comments
Filament Version
v3
Plugin Version
v2
PHP Version
8.1
Problem description
Using a Form Select inside the repeater with a createOptionForm
, the created option is saved and associated with the repeater relationship but, after save, the select is cleared. Refreshing the page then shows the select value.
TableRepeater::make('clientContacts')
->label('Contacts')
->relationship()
->schema([
Forms\Components\Select::make('contact_id')
->relationship('contact', 'name')
->required()
->searchable()
->createOptionForm([
Forms\Components\TextInput::make('name')
->required(),
Forms\Components\TextInput::make('email')
->email(),
Forms\Components\TextInput::make('office_phone')
->tel(),
Forms\Components\TextInput::make('mobile_phone')
->tel()
])->createOptionModalHeading('Create Contact'),
Forms\Components\TextInput::make('description')
])
Screen.Recording.2023-09-11.at.10.53.08.AM.mov
Expected behavior
The expected behavior is that the select value would remain after saving.
Steps to reproduce
In a form, add the TableRepeater referencing a relationship and within the TableRepeater schema, include a Select with a createOptionForm. Open an existing record that contains the TableRepeater and attempt to add a new relationship by clicking the suffix create action then save.
Reproduction repository
No response
Relevant log output
No response
I wonder if this is a bug in the filament repeater or a livewire issue? Can you update to the latest filament and if the issue is still there try to replicate it in a regular repeater?
This plugin uses the filament repeater under the hood it just changes the layout. So there's nothing in the plugin, that I can think of, that would have a direct conflict with saving data.
@awcodes Sorry I'm just getting back to you. I changed my form to use the Filament Repeater and the value is retained after save. Seems odd if you are using the Filament Repeater in the background but I can confirm it is behaving differently. Let me know how I can help.
If you could provide a reproduction repo, that would be a huge help.
I've created the repo and found that during create, the TableRepeater Select retains the created relationship but during edit, it does not. Provided high-level steps to reproduce in the readme. Hope this helps.
https://github.com/brianakidd/filament-table-repeater-error.git
Thank you. I will look at it as soon as I can and get back to you.