Skip to content

Commit

Permalink
No need to use static property for view
Browse files Browse the repository at this point in the history
  • Loading branch information
aerni committed Dec 9, 2023
1 parent 65a913f commit 46ad00f
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Fields/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Assets extends Field
{
use WithMultiple;

protected static string $view = 'assets';
protected string $view = 'assets';

protected function multipleProperty(): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Captcha extends Field
{
protected static string $view = 'captcha';
protected string $view = 'captcha';

public function process(mixed $value): mixed
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Checkboxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Checkboxes extends Field
use WithInline;
use WithOptions;

protected static string $view = 'checkboxes';
protected string $view = 'checkboxes';

protected function defaultProperty(): string|array|null
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Hidden.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

class Hidden extends Field
{
protected static string $view = 'default';
protected string $view = 'default';
}
2 changes: 1 addition & 1 deletion src/Fields/Honeypot.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

class Honeypot extends Field
{
protected static string $view = 'honeypot';
protected string $view = 'honeypot';
}
2 changes: 1 addition & 1 deletion src/Fields/Integer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Integer extends Field
use WithInputType;
use WithPlaceholder;

protected static string $view = 'default';
protected string $view = 'default';

protected function inputTypeProperty(): string
{
Expand Down
6 changes: 3 additions & 3 deletions src/Fields/Properties/WithView.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ protected function viewProperty(): string
{
// Try to load a user-defined view first.
if ($this->field->get('view')) {
return 'fields.'.$this->field->get('view');
return "fields.{$this->field->get('view')}";
}

// Try to autoload the view by field handle.
if (view()->exists("livewire-forms::fields.{$this->handle}")) {
return 'fields.'.$this->handle;
return "fields.{$this->handle}";
}

// Fall back to the default field view.
return 'fields.'.static::$view;
return "fields.{$this->view}";
}
}
2 changes: 1 addition & 1 deletion src/Fields/Radio.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Radio extends Field
use WithInline;
use WithOptions;

protected static string $view = 'radio';
protected string $view = 'radio';

protected function defaultProperty(): ?string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Select extends Field
use WithOptions;
use WithPlaceholder;

protected static string $view = 'select';
protected string $view = 'select';

protected function defaultProperty(): string|array|null
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Spacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

class Spacer extends Field
{
protected static string $view = 'spacer';
protected string $view = 'spacer';
}
2 changes: 1 addition & 1 deletion src/Fields/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Text extends Field
use WithInputType;
use WithPlaceholder;

protected static string $view = 'default';
protected string $view = 'default';

protected function hiddenProperty(): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Textarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ class Textarea extends Field
use WithPlaceholder;
use WithRows;

protected static string $view = 'textarea';
protected string $view = 'textarea';
}
2 changes: 1 addition & 1 deletion src/Fields/Toggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Toggle extends Field
{
use WithInlineLabel;

protected static string $view = 'toggle';
protected string $view = 'toggle';

protected function rulesProperty(): array
{
Expand Down

0 comments on commit 46ad00f

Please sign in to comment.