Dynamic fields based on a select option

Create time select to dynamic input field showing but edit time selected dropdown base input not showing.
Select::make('type')
->relationship('customerType', 'type')
->live()
->afterStateUpdated(fn (Select $component) => $component
->getContainer()
->getComponent('dynamicTypeFields')
->getChildComponentContainer()
->fill()),

Grid::make(2)
->schema(fn (Get $get): array => match ($get('type')) {
'1' => self::ipFields(),
'2' => self::pppoeFields(),
'3' => self::hotspotFields(),
default => [],
})->key('dynamicTypeFields'),
Select::make('type')
->relationship('customerType', 'type')
->live()
->afterStateUpdated(fn (Select $component) => $component
->getContainer()
->getComponent('dynamicTypeFields')
->getChildComponentContainer()
->fill()),

Grid::make(2)
->schema(fn (Get $get): array => match ($get('type')) {
'1' => self::ipFields(),
'2' => self::pppoeFields(),
'3' => self::hotspotFields(),
default => [],
})->key('dynamicTypeFields'),
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?