Created
August 18, 2023 21:19
-
-
Save awcodes/eda694866e62ff3287df2bd46610e7ba to your computer and use it in GitHub Desktop.
NowAction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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