Custom confirmation modal

Hello Community ! Could anyone advise me the best ‘filament way’ to have a custom confirmation in my case ? I have a calendar showing events which are linked to resources, like “teacher” or “classroom”. There are different ways to create or modify the events : 1. A classic form with a save action 2. The same form, but the user can click in the calendar to create the event on that day (not actual code for clarity)
<div x-on:click="$wire.onDayClick( {{$timestamp}} )" ... />
<div x-on:click="$wire.onDayClick( {{$timestamp}} )" ... />
#[On('onDayClick')]
public function onDayClick($day)
{
$this->validate();

$f=$this->getFormValuesAsArray();
$f['date'] = Carbon::createFromTimestamp($day)->toDateString();

// Ask confirmation if needed

$event = Event::create($f);

}
#[On('onDayClick')]
public function onDayClick($day)
{
$this->validate();

$f=$this->getFormValuesAsArray();
$f['date'] = Carbon::createFromTimestamp($day)->toDateString();

// Ask confirmation if needed

$event = Event::create($f);

}
3. Moving an event (drag & drop) between days
onEnd: function(evt) {
const eventId = evt.item.id;
const toDate = evt.to.dataset.statusId;
@this.dispatch('onEventDropped', {
eventId: eventId,
toDate: toDate
});
}
onEnd: function(evt) {
const eventId = evt.item.id;
const toDate = evt.to.dataset.statusId;
@this.dispatch('onEventDropped', {
eventId: eventId,
toDate: toDate
});
}
#[On(' onEventDropped ')]
public function onEventDropped($eventId, $toDate)
{
$day=Carbon::createFromTimestamp($toDate);
$event=Event::find($eventId);

// Ask confirmation if needed

$event->update(['date' => $day]);
}
#[On(' onEventDropped ')]
public function onEventDropped($eventId, $toDate)
{
$day=Carbon::createFromTimestamp($toDate);
$event=Event::find($eventId);

// Ask confirmation if needed

$event->update(['date' => $day]);
}
If one or more of the resources linked to the event is already occupied in another event, I’d like to ask confirmation to the user, and then proceed with the modification or cancel it. Case #1 can use requiresConfirmation() logic, this one is obvious. But for #2 and #3, I don’t see the ‘right’ way to do it… And of course, I’d like to have something that can be used in all the cases. Any ideas ? Thanks for your time
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server