mirror of
https://github.com/filamentphp/filament.git
synced 2026-10-24 12:04:06 +08:00
Merge pull request #684 from roni-estein/add-autocapitalize-attribute
Add autocapitalize attribute to maintained concerns
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
type="text"
|
||||
wire:ignore
|
||||
@endunless
|
||||
{!! ($autocapitalize = $getAutocapitalize()) ? "autocapitalize=\"{$autocapitalize}\"" : null !!}
|
||||
{!! ($autocomplete = $getAutocomplete()) ? "autocomplete=\"{$autocomplete}\"" : null !!}
|
||||
{!! $isAutofocused() ? 'autofocus' : null !!}
|
||||
{!! $isDisabled() ? 'disabled' : null !!}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
:state-path="$getStatePath()"
|
||||
>
|
||||
<textarea
|
||||
{!! ($autocapitalize = $getAutocapitalize()) ? "autocapitalize=\"{$autocapitalize}\"" : null !!}
|
||||
{!! ($autocomplete = $getAutocomplete()) ? "autocomplete=\"{$autocomplete}\"" : null !!}
|
||||
{!! $isAutofocused() ? 'autofocus' : null !!}
|
||||
{!! ($cols = $getCols()) ? "cols=\"{$cols}\"" : null !!}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Forms\Components\Concerns;
|
||||
|
||||
trait CanBeAutocapitalized
|
||||
{
|
||||
protected $autocapitalize = null;
|
||||
|
||||
public function autocapitalize(string | callable $autocapitalize = 'on'): static
|
||||
{
|
||||
$this->autocapitalize = $autocapitalize;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function disableAutocapitalize(bool | callable $condition = true): static
|
||||
{
|
||||
$this->autocapitalize(function () use ($condition): ?string {
|
||||
return $this->evaluate($condition) ? 'off' : null;
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAutocapitalize(): ?string
|
||||
{
|
||||
return $this->evaluate($this->autocapitalize);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Contracts\Support\Arrayable;
|
||||
|
||||
class TextInput extends Field
|
||||
{
|
||||
use Concerns\CanBeAutocapitalized;
|
||||
use Concerns\CanBeAutocompleted;
|
||||
use Concerns\CanBeLengthConstrained;
|
||||
use Concerns\HasPlaceholder;
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Filament\Forms\Components;
|
||||
|
||||
class Textarea extends Field
|
||||
{
|
||||
use Concerns\CanBeAutocapitalized;
|
||||
use Concerns\CanBeAutocompleted;
|
||||
use Concerns\CanBeLengthConstrained;
|
||||
use Concerns\HasPlaceholder;
|
||||
|
||||
Reference in New Issue
Block a user