Skip to content

Commit ae2bb47

Browse files
committed
Merge pull request #39 from erchecho/main
Update GoogleAutocomplete field processing to handle Hidden components
1 parent bcc23b4 commit ae2bb47

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Forms/Components/GoogleAutocomplete.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Closure;
66
use Filament\Forms\Components\Field;
7+
use Filament\Forms\Components\Hidden;
78
use Filament\Forms\Components\Select;
89
use Filament\Forms\Components\TextInput;
910
use Filament\Schemas\Components\Concerns\HasLabel;
@@ -106,8 +107,13 @@ protected function buildSchema(): array
106107
$googleFields = $this->getFormattedApiResults($data);
107108

108109
foreach ($this->getWithFields() as $field) {
109-
$fieldExtraAttributes = $field->getExtraInputAttributes();
110+
// Check if the field is a Hidden component or has getExtraInputAttributes method
111+
$fieldExtraAttributes = $field instanceof Hidden
112+
? $field->getExtraAttributes()
113+
: $field->getExtraInputAttributes();
114+
110115
$googleFieldName = count($fieldExtraAttributes) > 0 && isset($fieldExtraAttributes['data-google-field']) ? $fieldExtraAttributes['data-google-field'] : $field->getName();
116+
111117
$googleFieldValue = count($fieldExtraAttributes) > 0 && isset($fieldExtraAttributes['data-google-value']) ? $fieldExtraAttributes['data-google-value'] : 'long_name';
112118

113119
// if the field contains combined values

0 commit comments

Comments
 (0)