From c211227141739f8249a882251ae78da9fabc7500 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 3 Nov 2024 21:27:02 +0100 Subject: [PATCH] fix: add min/max length to input/texarea --- app/View/Components/Forms/Textarea.php | 4 +++- resources/views/components/forms/input.blade.php | 5 +++-- resources/views/components/forms/textarea.blade.php | 7 ++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/View/Components/Forms/Textarea.php b/app/View/Components/Forms/Textarea.php index 3f887877c..6081c2a8a 100644 --- a/app/View/Components/Forms/Textarea.php +++ b/app/View/Components/Forms/Textarea.php @@ -30,7 +30,9 @@ class Textarea extends Component public bool $realtimeValidation = false, public bool $allowToPeak = true, public string $defaultClass = 'input scrollbar font-mono', - public string $defaultClassInput = 'input' + public string $defaultClassInput = 'input', + public ?int $minlength = null, + public ?int $maxlength = null, ) { // } diff --git a/resources/views/components/forms/input.blade.php b/resources/views/components/forms/input.blade.php index fb206fac4..d832cb30d 100644 --- a/resources/views/components/forms/input.blade.php +++ b/resources/views/components/forms/input.blade.php @@ -41,8 +41,9 @@ @if ($id !== 'null') wire:model={{ $id }} @endif wire:dirty.class.remove='dark:focus:ring-coolgray-300 dark:ring-coolgray-300' wire:dirty.class="dark:focus:ring-warning dark:ring-warning" wire:loading.attr="disabled" - type="{{ $type }}" @disabled($disabled) - min="{{ $attributes->get('min') }}" max="{{ $attributes->get('max') }}" + type="{{ $type }}" @disabled($disabled) min="{{ $attributes->get('min') }}" + max="{{ $attributes->get('max') }}" minlength="{{ $attributes->get('minlength') }}" + maxlength="{{ $attributes->get('maxlength') }}" @if ($id !== 'null') id={{ $id }} @endif name="{{ $name }}" placeholder="{{ $attributes->get('placeholder') }}"> @endif diff --git a/resources/views/components/forms/textarea.blade.php b/resources/views/components/forms/textarea.blade.php index 24226ecdb..b3669e43d 100644 --- a/resources/views/components/forms/textarea.blade.php +++ b/resources/views/components/forms/textarea.blade.php @@ -51,8 +51,8 @@ type="{{ $type }}" @readonly($readonly) @disabled($disabled) id="{{ $id }}" name="{{ $name }}" placeholder="{{ $attributes->get('placeholder') }}" aria-placeholder="{{ $attributes->get('placeholder') }}"> -