From 2d951fdbede74844149ede486d909ecb1bc7aef8 Mon Sep 17 00:00:00 2001 From: Sam Maosa Date: Thu, 25 Aug 2022 20:56:17 +0300 Subject: [PATCH] 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