Skip to content

Commit

Permalink
Merge pull request #5 from savannabits/flatpickr-config-patch
Browse files Browse the repository at this point in the history
Added Ability to pass any flatpickr config to the component from the form field through the ->config([]) method which accepts a key-value array of any Flatpickr Option
  • Loading branch information
coolsam726 authored Aug 25, 2022
2 parents aebfb4b + 8b0d2b4 commit 9c42ea0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions resources/views/flatpickr.blade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@php
$config = [
$config =array_merge($getConfig(), [
"altInput" => $isAltInput(),
"enableTime" => $isEnableTime(),
"dateFormat" => $getDateFormat(),
];
]);
$attribs = [
"disabled" => $isDisabled(),
"theme" => $getTheme(),
Expand Down
21 changes: 21 additions & 0 deletions src/Flatpickr.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9c42ea0

Please sign in to comment.