diff --git a/resources/views/flatpickr.blade.php b/resources/views/flatpickr.blade.php index a14f26d..cf71f1d 100644 --- a/resources/views/flatpickr.blade.php +++ b/resources/views/flatpickr.blade.php @@ -1,9 +1,9 @@ @php - $config = [ + $config =array_merge($getConfig(), [ "altInput" => $isAltInput(), "enableTime" => $isEnableTime(), "dateFormat" => $getDateFormat(), - ]; + ]); $attribs = [ "disabled" => $isDisabled(), "theme" => $getTheme(), diff --git a/src/Flatpickr.php b/src/Flatpickr.php index d0815f2..6c2ac0e 100755 --- a/src/Flatpickr.php +++ b/src/Flatpickr.php @@ -21,6 +21,8 @@ class Flatpickr extends Field protected bool $altInput = true; + protected array $config = []; + protected ?string $altFormat = 'F j, Y'; protected bool $enableTime = false; @@ -48,6 +50,25 @@ public function isWeekSelect(): bool return $this->weekSelect; } + /** + * @param array $config + * @return Flatpickr + */ + public function config(array|\Closure $config): Flatpickr + { + $this->config = $config; + + return $this; + } + + /** + * @return array + */ + public function getConfig(): array + { + return $this->config; + } + /** * @param bool $rangePicker * @return Flatpickr