Skip to content
This repository has been archived by the owner on Dec 29, 2021. It is now read-only.

Commit

Permalink
Add custom-config parameter to DateField
Browse files Browse the repository at this point in the history
  • Loading branch information
masterix21 committed Sep 11, 2020
1 parent 0fed81e commit 78f720b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/View/Components/Form/DateField.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ class DateField extends Field
public string $valueFormat;
private ?string $mode;
public array $flatpickrConfig;
public array $customConfig;

public function __construct(?string $id = null, ?string $name = null, ?string $label = null, ?string $hint = null, ?string $help = null, ?string $errorBag = null, bool $disabled = false, bool $readOnly = false, $value = null, ?string $displayFormat = null, ?string $valueFormat = null, ?string $mode = null)
public function __construct(?string $id = null, ?string $name = null, ?string $label = null, ?string $hint = null, ?string $help = null, ?string $errorBag = null, bool $disabled = false, bool $readOnly = false, $value = null, ?string $displayFormat = null, ?string $valueFormat = null, ?string $mode = null, ?array $customConfig = null)
{
parent::__construct($id, $name, $label, $hint, $help, $errorBag, $disabled, $readOnly, $value);

$this->valueFormat = $valueFormat ?? 'Y-m-d';
$this->displayFormat = $displayFormat ?? $this->valueFormat;
$this->mode = $mode;

$this->customConfig = $customConfig ?? [];
$this->flatpickrConfig = $this->buildFlatpickrConfig();
}

Expand All @@ -36,7 +38,7 @@ private function buildFlatpickrConfig() : array
$config['mode'] = $this->mode;
}

return $config;
return array_merge($config, $this->customConfig);
}

public function render()
Expand Down

0 comments on commit 78f720b

Please sign in to comment.