diff --git a/resources/views/components/form/error.blade.php b/resources/views/components/form/error.blade.php
index 83071b6..aa3ffc4 100644
--- a/resources/views/components/form/error.blade.php
+++ b/resources/views/components/form/error.blade.php
@@ -1,21 +1,7 @@
-@props(['name', 'type' => 'text', 'multiple' => false])
+@props(['name'])
-@if($type === 'file' && $multiple)
- @foreach ($errors->get( rtrim($name, []) . '.*') as $messages)
- @foreach ($messages as $message)
-
- {{ $message }}
-
- @endforeach
- @endforeach
-@else
- @php
- $message = $errors->first($name);
- @endphp
-
- @if($message)
-
- {{ $message }}
-
- @endif
-@endif
\ No newline at end of file
+@error($name)
+
+ {{ $message }}
+
+@enderror
\ No newline at end of file
diff --git a/resources/views/components/form/input.blade.php b/resources/views/components/form/input.blade.php
index 6af963b..693fb8c 100644
--- a/resources/views/components/form/input.blade.php
+++ b/resources/views/components/form/input.blade.php
@@ -16,6 +16,7 @@
@if (! $isLivewire && ! empty($resolvedValue))
value="{{ $resolvedValue }}"
@endif
+ @if($multiple) multiple @endif
{{ $attributes->merge(['class' => $inputClasses]) }}
/>
@@ -24,5 +25,17 @@
{{ $help }}
@endif
-
+
+
+ @if($type === 'file' && $multiple)
+ @foreach($errors->get(rtrim($name, '[]') . '.*') as $error)
+
+ {{ $error[0] }}
+
+
+ @endforeach
+ @else
+
+ @endif
+
\ No newline at end of file
diff --git a/src/View/Components/Form/Concerns/InteractsWithFormField.php b/src/View/Components/Form/Concerns/InteractsWithFormField.php
index e3cee03..3d6126e 100644
--- a/src/View/Components/Form/Concerns/InteractsWithFormField.php
+++ b/src/View/Components/Form/Concerns/InteractsWithFormField.php
@@ -38,8 +38,22 @@ trait InteractsWithFormField
public function render(): View
{
+ $multipleInputFileHasError = false;
- if (session('errors')?->has($this->name)) {
+ if(isset($this->type) && isset($this->multiple)) {
+ if($this->type === 'file' && $this->multiple) {
+ if(session('errors') !== null)
+ {
+ foreach (session('errors')->getMessages() as $key => $error) {
+ if (str_starts_with($key, rtrim($this->name, '[]') . '.')) {
+ $multipleInputFileHasError = true;
+ }
+ }
+ }
+
+ }
+ }
+ if(session('errors')?->has($this->name) || $multipleInputFileHasError) {
$this->inputClasses .= ' input-error';
}
if($this->readonly)
diff --git a/src/View/Components/Form/Input.php b/src/View/Components/Form/Input.php
index c71fe04..36e30c7 100644
--- a/src/View/Components/Form/Input.php
+++ b/src/View/Components/Form/Input.php
@@ -19,6 +19,7 @@ class Input extends Component
* @param bool $required
* @param bool $disabled
* @param bool $readonly Will act as disabled, but keep an HTML-sendable value
+ * @param bool $multiple If true, the input will be a multiple file upload input.
* @param string $gridLayout The form section component offers a grid of 12 columns. Adjust this parameter as needed.
* @param mixed|null $value
* @param mixed|null $model If $model->$name exists, you can just set the model instead of a value.
@@ -33,6 +34,7 @@ class Input extends Component
public bool $required = false,
public bool $disabled = false,
public bool $readonly = false,
+ public bool $multiple = false,
public string $gridLayout = '',
public mixed $value = null,
public mixed $model = null,