Skip to content

Commit

Permalink
fix: cannot configure the file/image field is multiple if file size i…
Browse files Browse the repository at this point in the history
…s greater than zero
  • Loading branch information
cklei-carly committed Nov 11, 2024
1 parent dfccf5d commit b154893
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/FieldTypes/Configs/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ public function applyConfig(Forms\Components\Component $component): void
$component->directory($this->directory);
}

if ($this->multiple) {
$component->multiple();
}

if (! empty($this->acceptedFileTypes)) {
$component->acceptedFileTypes(array_filter($this->acceptedFileTypes));
}
Expand All @@ -123,17 +119,20 @@ public function applyConfig(Forms\Components\Component $component): void
}

if (! empty($this->fileLimit)) {
$isMultiple = false;
if (isset($this->fileLimit['min']) && $this->fileLimit['min'] > 0) {
$component->maxFiles(intval($this->fileLimit['min']));
$isMultiple = true;
$this->multiple = true;
}
if (isset($this->fileLimit['max']) && $this->fileLimit['max'] > 0) {
$component->maxFiles(intval($this->fileLimit['max']));
$isMultiple = true;
$this->multiple = true;
}
}

if ($this->multiple) {
$component->multiple();
}

$component->afterStateHydrated(function ($component, $state) {

if (is_null($state)) {
Expand Down

0 comments on commit b154893

Please sign in to comment.