Add postfix to fields

This commit is contained in:
Bernhard Hörmann
2021-05-12 13:22:55 +02:00
parent 89fc398400
commit 8664452b21
3 changed files with 29 additions and 0 deletions
@@ -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())
<span class="inline-flex items-center px-3 text-gray-500 border border-l-0 border-gray-300 rounded-r bg-gray-50 whitespace-nowrap sm:text-sm">
{!! $formComponent->getPostfix() !!}
</span>
@endif
</div>
</x-forms::field-group>
@@ -0,0 +1,22 @@
<?php
namespace Filament\Forms\Components\Concerns;
trait HasPostfix
{
protected $postfix;
public function getPostfix()
{
return $this->postfix;
}
public function postfix($postfix)
{
$this->configure(function () use ($postfix) {
$this->postfix = $postfix;
});
return $this;
}
}
@@ -11,6 +11,7 @@ class TextInput extends Field
use Concerns\CanBeLengthConstrained;
use Concerns\HasPlaceholder;
use Concerns\HasPrefix;
use Concerns\HasPostfix;
protected $type = 'text';