diff --git a/resources/views/fields/avatar.blade.php b/resources/views/fields/avatar.blade.php index 400a5f97a7..81cefa7f91 100644 --- a/resources/views/fields/avatar.blade.php +++ b/resources/views/fields/avatar.blade.php @@ -9,7 +9,7 @@ x-on:livewire-upload-progress="progress = $event.detail.progress" class="flex items-center space-x-4">
-
- + $value) - {{ $attribute }}="{{ $value }}" - @endforeach - @endif - @if ($model) - {{ $modelDirective }}="{{ $model }}" - @endif + id="{{ $id ?? $model }}" + @foreach ($extraAttributes as $attribute => $value) + {{ $attribute }}="{{ $value }}" + @endforeach />
diff --git a/resources/views/fields/checkbox.blade.php b/resources/views/fields/checkbox.blade.php index c870b0efa2..38a941e902 100644 --- a/resources/views/fields/checkbox.blade.php +++ b/resources/views/fields/checkbox.blade.php @@ -2,18 +2,12 @@ $value) - {{ $attribute }}="{{ $value }}" - @endforeach - @endif - class="rounded text-blue-700 shadow-sm focus:border-blue-700 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 @error($model ?? $name) border-red-600 @else border-gray-300 @enderror" /> + {{ $modelDirective }}="{{ $model }}" + value="{{ $value }}" + @foreach ($extraAttributes as $attribute => $value) + {{ $attribute }}="{{ $value }}" + @endforeach + class="rounded text-blue-700 shadow-sm focus:border-blue-700 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 @error($model) border-red-600 @else border-gray-300 @enderror" /> @if ($label) {{ $label }} @@ -26,7 +20,7 @@ - + @if ($help) @markdown($help) diff --git a/resources/views/fields/text.blade.php b/resources/views/fields/text.blade.php index fa3b019134..99941ca50c 100644 --- a/resources/views/fields/text.blade.php +++ b/resources/views/fields/text.blade.php @@ -2,16 +2,12 @@ @section('field') $value) - {{ $attribute }}="{{ $value }}" - @endforeach - @endif - class="block w-full rounded shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 @error($model ?? $name) border-red-600 motion-safe:animate-shake @else border-gray-300 @enderror" + {{ $modelDirective }}="{{ $model }}" + value="{{ $value }}" + id="{{ $id ?? $model }}" + @foreach ($extraAttributes as $attribute => $value) + {{ $attribute }}="{{ $value }}" + @endforeach + class="block w-full rounded shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 @error($model) border-red-600 motion-safe:animate-shake @else border-gray-300 @enderror" /> @overwrite \ No newline at end of file diff --git a/resources/views/fields/textarea.blade.php b/resources/views/fields/textarea.blade.php index 47d8ea44f4..412e4a8a68 100644 --- a/resources/views/fields/textarea.blade.php +++ b/resources/views/fields/textarea.blade.php @@ -2,16 +2,12 @@ @section('field') @overwrite \ No newline at end of file diff --git a/resources/views/fields/trix.blade.php b/resources/views/fields/trix.blade.php index a11acf740a..8429afeb4a 100644 --- a/resources/views/fields/trix.blade.php +++ b/resources/views/fields/trix.blade.php @@ -9,15 +9,22 @@ @endpushonce @section('field') -
- +
+ $value) + {{ $attribute }}="{{ $value }}" + @endforeach + />
- +
@@ -58,15 +65,10 @@ $value) - {{ $attribute }}="{{ $value }}" - @endforeach - @endif >
diff --git a/resources/views/layouts/field-group.blade.php b/resources/views/layouts/field-group.blade.php index 233eba8327..9606271d0a 100644 --- a/resources/views/layouts/field-group.blade.php +++ b/resources/views/layouts/field-group.blade.php @@ -1,7 +1,7 @@
@if ($label) - + {{ __($label) }} @endif @@ -12,7 +12,7 @@ @endif
@yield('field') - + @if ($help) @markdown($help) diff --git a/src/Fields/Field.php b/src/Fields/Field.php index 6cf6b30a64..4cfab9e3f6 100644 --- a/src/Fields/Field.php +++ b/src/Fields/Field.php @@ -5,21 +5,27 @@ namespace Filament\Fields; use Illuminate\Support\Str; class Field extends BaseField { - public $name; - public $label; public $model; - public $modelDirective; - public $extraAttributes; + public $value; + public $label; + public $modelDirective = 'wire:model.defer'; + public $extraAttributes = []; protected $view; - public function __construct($name) + public function __construct($model) { - $this->name = $name; + $this->model = $model; } - public static function make($name) + public static function make($model) { - return new static($name); + return new static($model); + } + + public function value($value) + { + $this->value = $value; + return $this; } public function label($label) @@ -28,10 +34,9 @@ class Field extends BaseField { return $this; } - public function model($model, $directive = 'wire:model.defer') + public function modelDirective($modelDirective) { - $this->model = $model; - $this->modelDirective = $directive; + $this->modelDirective = $modelDirective; return $this; } diff --git a/src/Http/Livewire/Auth/ForgotPassword.php b/src/Http/Livewire/Auth/ForgotPassword.php index e10300e47a..3b713e7c18 100644 --- a/src/Http/Livewire/Auth/ForgotPassword.php +++ b/src/Http/Livewire/Auth/ForgotPassword.php @@ -33,7 +33,6 @@ class ForgotPassword extends Component Text::make('email') ->type('email') ->label('E-Mail Address') - ->model('email') ->extraAttributes([ 'required' => 'true', 'autofocus' => 'true', diff --git a/src/Http/Livewire/Auth/Login.php b/src/Http/Livewire/Auth/Login.php index b51f260690..87f909e760 100644 --- a/src/Http/Livewire/Auth/Login.php +++ b/src/Http/Livewire/Auth/Login.php @@ -44,7 +44,6 @@ class Login extends Component Text::make('email') ->type('email') ->label('E-Mail Address') - ->model('email') ->extraAttributes([ 'required' => 'true', 'autocomplete' => 'email', @@ -57,15 +56,13 @@ class Login extends Component Text::make('password') ->type('password') ->label('Password') - ->model('password') ->extraAttributes([ 'required' => 'true', 'autocomplete' => 'current-password', ]) ->hint('['.__('Forgot Your Password?').']('.route('filament.password.forgot').')'), Checkbox::make('remember') - ->label('Remember me') - ->model('remember'), + ->label('Remember me'), ]; } diff --git a/src/Http/Livewire/Auth/Register.php b/src/Http/Livewire/Auth/Register.php index a1b07fd58d..9b0543a4e7 100644 --- a/src/Http/Livewire/Auth/Register.php +++ b/src/Http/Livewire/Auth/Register.php @@ -33,7 +33,6 @@ class Register extends Component return [ Text::make('name') ->label('Name') - ->model('name') ->extraAttributes([ 'required' => 'true', 'autofocus' => 'true', @@ -42,7 +41,7 @@ class Register extends Component Text::make('email') ->type('email') ->label('E-Mail Address') - ->model('email', 'wire:model.lazy') + ->modelDirective('wire:model.lazy') ->extraAttributes([ 'required' => 'true', 'autocomplete' => 'email', @@ -50,7 +49,6 @@ class Register extends Component Text::make('password') ->type('password') ->label('Password') - ->model('password',) ->extraAttributes([ 'required' => 'true', 'autocomplete' => 'new-password', @@ -58,7 +56,6 @@ class Register extends Component Text::make('password_confirmation') ->type('password') ->label('Confirm New Password') - ->model('password_confirmation',) ->extraAttributes([ 'required' => 'true', 'autocomplete' => 'new-password', diff --git a/src/Http/Livewire/Auth/ResetPassword.php b/src/Http/Livewire/Auth/ResetPassword.php index 7fd51965cc..ceabf17bac 100644 --- a/src/Http/Livewire/Auth/ResetPassword.php +++ b/src/Http/Livewire/Auth/ResetPassword.php @@ -61,7 +61,7 @@ class ResetPassword extends Component Text::make('email') ->type('email') ->label('E-Mail Address') - ->model('email', 'wire:model.lazy') + ->modelDirective('wire:model.lazy') ->extraAttributes([ 'required' => 'true', 'autocomplete' => 'email', @@ -69,7 +69,6 @@ class ResetPassword extends Component Text::make('password') ->type('password') ->label('Password') - ->model('password',) ->extraAttributes([ 'required' => 'true', 'autofocus' => 'true', @@ -78,7 +77,6 @@ class ResetPassword extends Component Text::make('password_confirmation') ->type('password') ->label('Confirm New Password') - ->model('password_confirmation',) ->extraAttributes([ 'required' => 'true', 'autocomplete' => 'new-password', diff --git a/src/Http/Livewire/Profile.php b/src/Http/Livewire/Profile.php index b2126922ea..7be27a27ba 100644 --- a/src/Http/Livewire/Profile.php +++ b/src/Http/Livewire/Profile.php @@ -82,23 +82,21 @@ class Profile extends Component return [ Tabs::label('Profile') ->tab('Account', [ - Text::make('name') + Text::make('user.name') ->label('Name') - ->model('user.name') ->extraAttributes([ 'required' => 'true', ]), - Text::make('email') + Text::make('user.email') ->type('email') ->label('E-Mail Address') - ->model('user.email', 'wire:model.lazy') + ->modelDirective('wire:model.lazy') ->extraAttributes([ 'required' => 'true', 'autocomplete' => 'email', ]), Avatar::make('avatar') ->label('User Photo') - ->model('avatar') ->avatar($this->avatar) ->user($this->user) ->delete('deleteAvatar') @@ -108,7 +106,6 @@ class Profile extends Component Text::make('password') ->type('password') ->label('Password') - ->model('password',) ->extraAttributes([ 'autocomplete' => 'new-password', ]) @@ -117,7 +114,6 @@ class Profile extends Component Text::make('password_confirmation') ->type('password') ->label('Confirm New Password') - ->model('password_confirmation',) ->extraAttributes([ 'autocomplete' => 'new-password', ])