Using query params while working with actions

i have the following code, i'm passing url params to the create page, to either show/hide inputs in the form, but the generate action is making the input dissapear
is there a better way to do this
Forms\Components\Section::make()
      ->schema([
          Forms\Components\TextInput::make('code')
              ->label('Coupon code')
              ->suffixAction(
                                                                  Forms\Components\Actions\Action::make('generate')
            ->label('Generate')
            ->color('gray')
            ->link()
            ->icon('heroicon-o-cog-8-tooth')
            ->action(function (Set $set) {
                $set('code',  strtoupper(Str::random(12)));
                                            })
                                    )
                                    ->visible(fn() => request()->get('type') === 'coupon' ? true : false)
                                    ->hint('Customers will enter this coupon code when they checkout.'),

                                Forms\Components\TextInput::make('promotionName')
                                    ->placeholder('Enter promotion name')
                                    ->visible(fn() => request()->get('type') === 'promotion' ? true : false),
                            ]),
Was this page helpful?