From 8664452b218374c90818280cd1fe44ee2341b74c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20H=C3=B6rmann?= Date: Wed, 12 May 2021 13:22:55 +0200 Subject: [PATCH] Add postfix to fields --- .../views/components/text-input.blade.php | 6 +++++ .../src/Components/Concerns/HasPostfix.php | 22 +++++++++++++++++++ packages/forms/src/Components/TextInput.php | 1 + 3 files changed, 29 insertions(+) create mode 100644 packages/forms/src/Components/Concerns/HasPostfix.php diff --git a/packages/forms/resources/views/components/text-input.blade.php b/packages/forms/resources/views/components/text-input.blade.php index 2434a927cb..d7aa263494 100644 --- a/packages/forms/resources/views/components/text-input.blade.php +++ b/packages/forms/resources/views/components/text-input.blade.php @@ -28,5 +28,11 @@ class="block w-full rounded-r placeholder-gray-400 focus:placeholder-gray-500 placeholder-opacity-100 focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50 {{ ! $formComponent->getPrefix() ? 'rounded-l-md' : null }} {{ $errors->has($formComponent->getName()) ? 'border-danger-600 motion-safe:animate-shake' : 'border-gray-300' }}" {!! Filament\format_attributes($formComponent->getExtraAttributes()) !!} /> + + @if ($formComponent->getPostfix()) + + {!! $formComponent->getPostfix() !!} + + @endif diff --git a/packages/forms/src/Components/Concerns/HasPostfix.php b/packages/forms/src/Components/Concerns/HasPostfix.php new file mode 100644 index 0000000000..f3842c613d --- /dev/null +++ b/packages/forms/src/Components/Concerns/HasPostfix.php @@ -0,0 +1,22 @@ +postfix; + } + + public function postfix($postfix) + { + $this->configure(function () use ($postfix) { + $this->postfix = $postfix; + }); + + return $this; + } +} diff --git a/packages/forms/src/Components/TextInput.php b/packages/forms/src/Components/TextInput.php index 4d259d7fb6..3580ba92db 100644 --- a/packages/forms/src/Components/TextInput.php +++ b/packages/forms/src/Components/TextInput.php @@ -11,6 +11,7 @@ class TextInput extends Field use Concerns\CanBeLengthConstrained; use Concerns\HasPlaceholder; use Concerns\HasPrefix; + use Concerns\HasPostfix; protected $type = 'text';