Skip to content

Commit

Permalink
Toggle: allow to pass id (#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
robsontenorio authored Nov 12, 2024
1 parent 2a7938b commit bd34eda
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/View/Components/Toggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Toggle extends Component
public string $uuid;

public function __construct(
public ?string $id = null,
public ?string $label = null,
public ?string $hint = null,
public ?bool $right = false,
Expand All @@ -22,7 +23,7 @@ public function __construct(
public ?bool $omitError = false,
public ?bool $firstErrorOnly = false,
) {
$this->uuid = "mary" . md5(serialize($this));
$this->uuid = "mary" . md5(serialize($this)) . $id;
}

public function modelName(): ?string
Expand All @@ -44,7 +45,7 @@ public function render(): View|Closure|string
@if($right)
<span @class(["flex-1" => !$tight])>
{{ $label}}
@if($attributes->get('required'))
<span class="text-error">*</span>
@endif
Expand All @@ -55,7 +56,7 @@ public function render(): View|Closure|string
@if(!$right)
{{ $label}}
@if($attributes->get('required'))
<span class="text-error">*</span>
@endif
Expand Down

0 comments on commit bd34eda

Please sign in to comment.