Browse Source

translate fix

Andrew 2 months ago
parent
commit
7d98f5cc18
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      app/Filament/Resources/ProjectResource.php

+ 9
- 1
app/Filament/Resources/ProjectResource.php View File

177
                             TextInput::make('offical_link')->label('官網連結'),
177
                             TextInput::make('offical_link')->label('官網連結'),
178
                         ])->columnSpanFull(),
178
                         ])->columnSpanFull(),
179
                         Repeater::make('spaceInfos')->label('')->schema([
179
                         Repeater::make('spaceInfos')->label('')->schema([
180
+                            TextInput::make('spaceInfos_item_key')
181
+                                ->default(fn () => Str::random())
182
+                                ->hidden()
183
+                                ->afterStateHydrated(function (TextInput $component, $state) {
184
+                                    if (empty($state)) {
185
+                                        $component->state(Str::random());
186
+                                    }
187
+                                }),
180
                             Translate::make()->schema(fn (string $locale) => [
188
                             Translate::make()->schema(fn (string $locale) => [
181
                                 TextInput::make('title')->label('標題')->columnSpanFull(),
189
                                 TextInput::make('title')->label('標題')->columnSpanFull(),
182
                                 Textarea::make('content')->label('內文')->columnSpanFull(),
190
                                 Textarea::make('content')->label('內文')->columnSpanFull(),
185
                                 ->actions([
193
                                 ->actions([
186
                                     app(DeepLService::class)->createTranslationAction('spaceInfos', ['title', 'content']),
194
                                     app(DeepLService::class)->createTranslationAction('spaceInfos', ['title', 'content']),
187
                                 ])->columnSpanFull()
195
                                 ])->columnSpanFull()
188
-                                ->id(fn ($get) => 'spaceInfos_'.$get('item_key')),
196
+                                ->id(fn ($get) => 'spaceInfos_'.$get('spaceInfos_item_key')),
189
                         ])
197
                         ])
190
                             ->relationship('spaceInfos')
198
                             ->relationship('spaceInfos')
191
                             ->label('')
199
                             ->label('')