FilamentF
Filament13mo ago
Xavi

Alert before create button on list

Is it possible to show and alert before create modal its show?. I want to alert user that he has made X questions before create it.

This is my header actions code:

protected function getHeaderActions(): array
    {
        return [
            CreateAction::make()
                ->label(__('Nueva pregunta'))
                ->visible(fn(): bool => Carbon::parse($this->record->allow_questions_from)->startOfDay()->lte(Carbon::now()->startOfDay()) &&
                    Carbon::parse($this->record->allow_questions_to)->endOfDay()->gte(Carbon::now()->endOfDay())
                )
                ->form([
                    Select::make('teacher_id')
                        ->label(__('Teacher'))
                        ->options($this->record->users->pluck('name', 'id')->toArray())
                        ->placeholder(__('Selecciona un docente'))
                        ->visible($this->record->users->count() > 1)
                        ->required(),
                    TextInput::make('subject')
                        ->label(__('Temática'))
                        ->required(),
                    Textarea::make('content')
                        ->label(__('Escribe tu pregunta'))
                        ->rows(10)
                        ->required(),
                ])
                ->action(
                    function (array $data) {
                        $question = CreateQuestionAction::run($data + ['module_id' => $this->record->id]);

                        $this->dispatch('open-modal', id: 'thank-you-modal', parameters: [
                            'question' => $question,
                        ]);
                    })
                ->createAnother(false)
                ->modalHeading('')
                ->icon('heroicon-o-plus')
        ];
    }


Thanks!
Was this page helpful?