What happened?
I'm a newer developer, so I apologize if my explanation is unclear or if my reasoning is off. I've hopefully done a sufficient job describing the issue accurately, but please let me know if anything needs further clarification!
When using the GoogleAutocomplete component inside a Repeater field in Filament, the withFields functionality does not behave as expected. Specifically, the fields bound via withFields appear to be linked across all repeater items, causing changes in one repeater item to update the same fields in all other items.
Reproduction Steps:
Add the following Repeater configuration to a Filament form:
Forms\Components\Repeater::make('addresses')
->relationship()
->label('Addresses')
->addActionLabel('Add Address')
->schema([
GoogleAutocomplete::make('location_search')
->label('Google Places')
->autocompleteLabel('Search')
->countries(['US'])
->language('en')
->autocompleteSearchDebounce(1000)
->withFields([
Forms\Components\TextInput::make('street')
->extraInputAttributes(['data-google-field' => '{street_number} {route}']),
Forms\Components\TextInput::make('city')
->extraInputAttributes(['data-google-field' => 'locality']),
Forms\Components\TextInput::make('state')
->extraInputAttributes(['data-google-field' => 'administrative_area_level_1']),
Forms\Components\TextInput::make('zipcode')
->extraInputAttributes(['data-google-field' => 'postal_code']),
Forms\Components\TextInput::make('latitude')
->extraInputAttributes(['data-google-field' => 'latitude']),
Forms\Components\TextInput::make('longitude')
->extraInputAttributes(['data-google-field' => 'longitude']),
]),
])
Expected Behavior:
Each repeater item should maintain its own independent state for the withFields mappings. Selecting a location in one item should not override or affect the fields in other repeater items.
Actual Behavior:
All instances of GoogleAutocomplete inside the Repeater share state, causing changes in one item to propagate across all items in the repeater.
How to reproduce the bug
1. Add the GoogleAutocomplete component inside a Repeater field.
2. Add the first address and select a location. (Working with one item in a repeater field works as intended)
3. Add a second address (new repeater item) and select a different location.
4. Observe that when selecting a location in the second repeater item, the fields mapped via withFields (e.g., street, city, state, zipcode) in the first repeater item also update.
-- The UI might not update it's values to show this.
5. If attempting to save the form to a database, an error occurs indicating that the first repeater item (index 0) is missing required field values.
This happens because the withFields mappings are not isolated per repeater item. Instead, all repeater items share the same underlying field bindings, resulting in only one set of data being updated while the database expects independent values for each address.
As for the version numbers listed below, I have copied and pasted directly from my composer.json file as to not avoid any confusion. I hope these are the version numbers you are looking for - and - let me know if not!
Package Version
"tapp/filament-google-autocomplete-field": "^1.0"
PHP Version
"php": "^8.2"
Laravel Version
"laravel/framework": "^11.0",
Which operating systems does with happen with?
macOS, Windows, Linux
Notes
- This issue only occurs when GoogleAutocomplete is inside a Repeater.
- Outside of a repeater (or when the repeater only has one item), the withFields mapping works correctly.
- This suggests that the GoogleAutocomplete component may not be properly isolating field bindings when inside dynamically generated repeater items.
- Would love any insight on whether this is a limitation of the Filament GoogleAutocomplete component or if there’s a workaround available. Thanks!
What happened?
I'm a newer developer, so I apologize if my explanation is unclear or if my reasoning is off. I've hopefully done a sufficient job describing the issue accurately, but please let me know if anything needs further clarification!
When using the GoogleAutocomplete component inside a Repeater field in Filament, the withFields functionality does not behave as expected. Specifically, the fields bound via withFields appear to be linked across all repeater items, causing changes in one repeater item to update the same fields in all other items.
Reproduction Steps:
Add the following Repeater configuration to a Filament form:
Expected Behavior:
Each repeater item should maintain its own independent state for the withFields mappings. Selecting a location in one item should not override or affect the fields in other repeater items.
Actual Behavior:
All instances of GoogleAutocomplete inside the Repeater share state, causing changes in one item to propagate across all items in the repeater.
How to reproduce the bug
1. Add the GoogleAutocomplete component inside a Repeater field.
2. Add the first address and select a location. (Working with one item in a repeater field works as intended)
3. Add a second address (new repeater item) and select a different location.
4. Observe that when selecting a location in the second repeater item, the fields mapped via withFields (e.g., street, city, state, zipcode) in the first repeater item also update.
-- The UI might not update it's values to show this.
5. If attempting to save the form to a database, an error occurs indicating that the first repeater item (index 0) is missing required field values.
This happens because the withFields mappings are not isolated per repeater item. Instead, all repeater items share the same underlying field bindings, resulting in only one set of data being updated while the database expects independent values for each address.
As for the version numbers listed below, I have copied and pasted directly from my composer.json file as to not avoid any confusion. I hope these are the version numbers you are looking for - and - let me know if not!
Package Version
"tapp/filament-google-autocomplete-field": "^1.0"
PHP Version
"php": "^8.2"
Laravel Version
"laravel/framework": "^11.0",
Which operating systems does with happen with?
macOS, Windows, Linux
Notes