F
Filament15mo ago
oRieN

Value inside Array not saving when editing

Section::make()
->schema([
Forms\Components\Select::make('type')
->required()
->disabledOn('edit')
->options([
'web-page' => 'Web Page',
])
->live()
->afterStateUpdated(fn (Select $component) => $component
->getContainer()
->getComponent('dynamicTypeFields')
->getChildComponentContainer()
->fill()
),

Grid::make(1)
->statePath('content')
->schema(fn (Get $get): array => match ($get('type')) {
'web-page' => [
Forms\Components\TextInput::make('url')
->label('URL')
->required()
->disableOn('edit')
->helperText("Note: this type won't provide statistics"),
],
default => [],
})
->key('dynamicTypeFields'),
]),
Section::make()
->schema([
Forms\Components\Select::make('type')
->required()
->disabledOn('edit')
->options([
'web-page' => 'Web Page',
])
->live()
->afterStateUpdated(fn (Select $component) => $component
->getContainer()
->getComponent('dynamicTypeFields')
->getChildComponentContainer()
->fill()
),

Grid::make(1)
->statePath('content')
->schema(fn (Get $get): array => match ($get('type')) {
'web-page' => [
Forms\Components\TextInput::make('url')
->label('URL')
->required()
->disableOn('edit')
->helperText("Note: this type won't provide statistics"),
],
default => [],
})
->key('dynamicTypeFields'),
]),
When editing a resource with this fields when I save, the field (web-page) URL goes empty but if i put readonlyOn its fine. The thing is i have other disabledOn('edit') field that still save and dont get empty the webpage URL goes into an json is this a bug or i'm doing something wrong?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server