From c8db7e1678b28280ae61208d043baf8881c68907 Mon Sep 17 00:00:00 2001 From: Sam Maosa Date: Thu, 25 Aug 2022 20:50:34 +0300 Subject: [PATCH 1/3] Update flatpickr.blade.php Merge config with the default config passed from the backend --- resources/views/flatpickr.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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(), From 2d951fdbede74844149ede486d909ecb1bc7aef8 Mon Sep 17 00:00:00 2001 From: Sam Maosa Date: Thu, 25 Aug 2022 20:56:17 +0300 Subject: [PATCH 2/3] Add Backend config() method Added config method to allow the user to pass any flatpickr config to the component from the form field. --- src/Flatpickr.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Flatpickr.php b/src/Flatpickr.php index d0815f2..e518bfc 100755 --- a/src/Flatpickr.php +++ b/src/Flatpickr.php @@ -20,6 +20,8 @@ class Flatpickr extends Field protected bool $multiplePicker = false; protected bool $altInput = true; + + protected array $config = []; protected ?string $altFormat = 'F j, Y'; @@ -47,6 +49,24 @@ 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 From 8b0d2b4b4d0c3208c1efb884fead63e9b66142d0 Mon Sep 17 00:00:00 2001 From: coolsam726 Date: Thu, 25 Aug 2022 17:56:44 +0000 Subject: [PATCH 3/3] Fix styling --- src/Flatpickr.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Flatpickr.php b/src/Flatpickr.php index e518bfc..6c2ac0e 100755 --- a/src/Flatpickr.php +++ b/src/Flatpickr.php @@ -20,7 +20,7 @@ class Flatpickr extends Field protected bool $multiplePicker = false; protected bool $altInput = true; - + protected array $config = []; protected ?string $altFormat = 'F j, Y'; @@ -49,17 +49,18 @@ public function isWeekSelect(): bool { return $this->weekSelect; } - + /** - * @param array $config + * @param array $config * @return Flatpickr */ public function config(array|\Closure $config): Flatpickr { $this->config = $config; + return $this; } - + /** * @return array */