FilamentF
Filament3y ago
N1XN

Steps in CreateAction sets only last steps formData

When submitting the form and inspecting the before() methods $data only the data from the last step is set, resulting in failed inserts as the data from first step is required. Am I using a relation manager, but this should not be any issue I guess.

In the below example $data['milk'] does not exist in before()

use Filament\Forms\Components\Wizard\Step;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Resources\Table;
use Filament\Tables\Actions\CreateAction;

class FoodRelationManager extends RelationManager
{
    protected static string $relationship = ‘foods’;

    protected static ?string $recordTitleAttribute = 'id';

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
        //
            ])
            ->filters([
                //
            ])
            ->headerActions([
                CreateAction::make('create')
                    ->steps([
                        Step::make(‘First’)
                            ->columns(2)
                            ->schema([
                                TextInput::make(‘milk’)
                                    ->numeric()
                                    ->required(),
                            ]),
                        Step::make(‘Second’)
                            ->schema([
                               TextInput::make(‘bread’)
                    ->required(),
                            ]),
                    ])
                    ->before(function ($data) {
              return $data;
                    })
            ])
            ->actions([
        //
            ]);
    }
}
Was this page helpful?