This commit is contained in:
Dan Harrin
2021-04-23 23:35:27 +01:00
parent 2e5ad84d93
commit e91cf1e740
6 changed files with 30 additions and 18 deletions
@@ -7,8 +7,8 @@
:label="$formComponent->getLabel()"
:required="$formComponent->isRequired()"
>
@if($formComponent->isInlineLayout())
<x-slot name="labelPrefix">
@if ($formComponent->isInline())
<x-slot name="labelPrefix">
@endif
<input
{!! $formComponent->isAutofocused() ? 'autofocus' : null !!}
@@ -20,7 +20,7 @@
class="rounded text-primary-600 shadow-sm focus:border-primary-700 focus:ring focus:ring-blue-200 focus:ring-opacity-50 {{ $errors->has($formComponent->getName()) ? 'border-danger-600 ' : 'border-gray-300' }}"
{!! Filament\format_attributes($formComponent->getExtraAttributes()) !!}
/>
@if($formComponent->isInlineLayout())
</x-slot>
@if ($formComponent->isInline())
</x-slot>
@endif
</x-forms::field-group>
@@ -7,8 +7,8 @@
:label="$formComponent->getLabel()"
:required="$formComponent->isRequired()"
>
@if($formComponent->isInlineLayout())
<x-slot name="labelPrefix">
@if ($formComponent->isInline())
<x-slot name="labelPrefix">
@endif
<button
x-data="{ value: @entangle($formComponent->getName()){{ Str::of($formComponent->getBindingAttribute())->after('wire:model') }} }"
@@ -61,7 +61,7 @@
</span>
</span>
</button>
@if($formComponent->isInlineLayout())
</x-slot>
@if ($formComponent->isInline())
</x-slot>
@endif
</x-forms::field-group>
+4 -2
View File
@@ -5,10 +5,12 @@ namespace Filament\Forms\Components;
class Checkbox extends Field
{
use Concerns\CanBeAutofocused;
use Concerns\CanAlternateLayoutDirection;
use Concerns\CanBeInline;
protected function setUp()
{
$this->default(false)->inline();
$this->default(false);
$this->inline();
}
}
@@ -2,14 +2,14 @@
namespace Filament\Forms\Components\Concerns;
trait CanAlternateLayoutDirection
trait CanBeInline
{
protected $isInlineLayout = false;
protected $isInline = false;
public function inline()
{
$this->configure(function () {
$this->isInlineLayout = true;
$this->isInline = true;
});
return $this;
@@ -18,14 +18,14 @@ trait CanAlternateLayoutDirection
public function stacked()
{
$this->configure(function () {
$this->isInlineLayout = false;
$this->isInline = false;
});
return $this;
}
public function isInlineLayout(): bool
public function isInline()
{
return $this->isInlineLayout;
return $this->isInline;
}
}
+4 -2
View File
@@ -8,7 +8,7 @@ use Filament\Forms\Components\Field;
class Toggle extends Field
{
use Concerns\CanBeAutofocused;
use Concerns\CanAlternateLayoutDirection;
use Concerns\CanBeInline;
protected $onIcon;
@@ -16,7 +16,9 @@ class Toggle extends Field
protected function setUp()
{
$this->default(false)->inline();
$this->default(false);
$this->inline();
}
public function onIcon($icon)
@@ -0,0 +1,8 @@
<?php
namespace Filament\Resources\Forms\Components\Concerns;
trait CanBeInline
{
use \Filament\Forms\Components\Concerns\CanBeInline;
}