Skip to content

Instantly share code, notes, and snippets.

@awcodes
Created August 18, 2023 21:19
Show Gist options
  • Save awcodes/eda694866e62ff3287df2bd46610e7ba to your computer and use it in GitHub Desktop.
Save awcodes/eda694866e62ff3287df2bd46610e7ba to your computer and use it in GitHub Desktop.
NowAction
<?php
namespace ...
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Set;
class NowAction extends Action
{
protected function setUp(): void
{
$this
->label(__'Now'))
->icon('heroicon-o-clock')
->action(function (DateTimePicker $component, Set $set) {
$set($component->getName(), now()->format($component->getFormat()));
});
}
}
// usage
DatePicker::make('published_at')
->suffixAction(NowAction::make('now_published_at')):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment