FilamentF
Filament3y ago
ico

Reactive field inside a dynamic generated schema Filament v3

I have a schema that is generated dynamicly like so based on a selected field
Section::make('AQL Report Form')
    ->schema([
        TextInput::make('limitCardNumber')
            ->label('Limit Card')
            ->disabled(true),
        TextInput::make('orderQuantity')
            ->label('Order Quantity')
            ->disabled(true),
        Select::make('stageId')
            ->options($this->stages)
            ->label('Stage')
            ->afterStateUpdated(function (Set $set, Get $get) {
                $this->updateDefects($this->stageId, $set); // <----- this fills the $defectListSchema property
            })
            ->reactive(),
    ])->columns(3),

Section::make('Defect List')
    ->schema(function () {
        return $this->defectListSchema;
    })
    ->hidden(function () {
        return $this->hideDefectList;
    }),


And the $this->defectListSchema contains many fields like this

Section::make('')->schema([
    TextInput::make('')->label('Defect')
        ->placeholder($defect['name'])
        ->disabled(true)
        ->columnSpan(2),
    TextInput::make('')->label('Inspection Level')
        ->placeholder($inspectionLevel->name)
        ->disabled(true),
    TextInput::make('')->label('Sample Size')
        ->placeholder($aqlLabel->sample)
        ->disabled(true),
    TextInput::make('numberOfDefects')
        ->numeric()
        ->label('Number of defects')
        ->afterStateUpdated(function (Set $set, Get $get) {
            // PTR compare and save data
        })
        ->reactive(),
])->columns(3),


But when i type anything in the numberOfDefects field that is reactive the entire form goes blank, disappears.

What could be the problem ?
Was this page helpful?