Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Closure at min and max date #49

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/Forms/Components/Flatpickr.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Filament\Forms\Components\Contracts;
use Filament\Forms\Components\Field;
use Filament\Support\Concerns\HasExtraAlpineAttributes;
use Closure;

class Flatpickr extends Field implements Contracts\CanBeLengthConstrained, Contracts\HasAffixActions
{
Expand Down Expand Up @@ -85,9 +86,9 @@ class Flatpickr extends Field implements Contracts\CanBeLengthConstrained, Contr

protected bool $inline = false;

protected Carbon|string|null $maxDate = null;
protected Carbon|string|null|Closure $maxDate = null;

protected Carbon|string|null $minDate = null;
protected Carbon|string|null|Closure $minDate = null;

protected ?string $maxTime = null;

Expand Down Expand Up @@ -477,7 +478,7 @@ public function getMaxDate(): Carbon|string|null
return $this->maxDate;
}

public function maxDate(Carbon|string|null $maxDate = 'now'): static
public function maxDate(Carbon|string|null|Closure $maxDate = 'now'): static
{
$this->maxDate = $maxDate ? Carbon::parse($maxDate) : $maxDate;

Expand All @@ -489,7 +490,7 @@ public function getMinDate(): Carbon|string|null
return $this->minDate;
}

public function minDate(Carbon|string|null $minDate): static
public function minDate(Carbon|string|null $minDate|Closure): static
{
$this->minDate = $minDate ? Carbon::parse($minDate) : $minDate;

Expand Down