I have the following code for filament v3. It's opening a modal when the type is 'hour'.
Unfurtunatly this is no longer working after upgrade te v=filament v4. Can someone please help me?
protected static function getArticleSelectionField(): Select
{
return Select::make('article_id')
->label('Article')
->relationship('article', 'name')
->live()
->afterStateUpdated(function (Get $get, Set $set, $state, $livewire, $component) {
$set('quantity', $article->unit === 'hour' ? 0 : 1);
// Auto-open the modal if unit is hour
if ($article->unit === 'hour') {
$livewire->mountFormComponentAction(
$component->getStatePath(),
'show_time_modal'
);
}
})
->registerActions([
Action::make('show_time_modal')
->label('Calculate T')
->modalHeading('Work C')
->form([
TimePicker::make('from_time')->required()->seconds(false),
TimePicker::make('to_time')->required()->seconds(false),
])
->action(function (array $data, Get $get, Set $set) {
$from = \Carbon\Carbon::parse($data['from_time']);
$to = \Carbon\Carbon::parse($data['to_time']);
.....
})
->mountUsing(function ($form) {
$form->fill([
'from_time' => now()->format('H:i'),
'to_time' => now()->addHour()->format('H:i'),
]);
})
->modalSubmitActionLabel('Apply')
->modalCancelActionLabel('Cancel'),
]);
}