Insert value from one field to another

Hi,

I would like to auto generate the email for my user form from the first and lastname.

I tried this, but it didn't work:
            CreateAction::make()->form([
                Grid::make(2)->schema([
                    TextInput::make('firstname')
                             ->reactive()
                             ->required(),
                    TextInput::make('lastname')
                             ->reactive(),
                             ->required(),
                ]),
                TextInput::make('email')
                         ->suffix('@company.com')
                         ->default(fn($get) => $get('firstname') . '.' . $get('lastname'))
                         ->unique()
                         ->required()
            ]);


How can I make this work?

Thank you!
Was this page helpful?