Skip to content

Commit

Permalink
fix indexed nested array model (#421)
Browse files Browse the repository at this point in the history
* Update DatePicker.php

fix indexed nested array model

* Update Input.php

fix indexed nested array model for money input
  • Loading branch information
behvandi11 committed May 8, 2024
1 parent 9d190c3 commit 0556e80
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/View/Components/DatePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function setup(): string
$config = str_replace('"#plugins#"', $plugins, $config);

// Sets default date as current bound model
$config = str_replace('"#model#"', '$wire.' . $this->modelName(), $config);
$config = str_replace('"#model#"', '$wire.entangle("' . $this->modelName().'").initialValue', $config);

return $config;
}
Expand Down
4 changes: 2 additions & 2 deletions src/View/Components/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function render(): View|Closure|string
@if($money)
<div
wire:key="money-{{ rand() }}"
x-data="{ amount: $wire.{{ $modelName() }} }" x-init="$nextTick(() => new Currency($refs.myInput, {{ $moneySettings() }}))"
x-data="{ amount: $wire.entangle('{{ $modelName() }}') }" x-init="$nextTick(() => new Currency($refs.myInput, {{ $moneySettings() }}))"
>
@endif
Expand All @@ -115,7 +115,7 @@ public function render(): View|Closure|string
@if($money)
x-ref="myInput"
:value="amount"
@input="$nextTick(() => $wire.{{ $modelName() }} = Currency.getUnmasked())"
@input="$nextTick(() => amount = Currency.getUnmasked())"
inputmode="numeric"
@endif
Expand Down

0 comments on commit 0556e80

Please sign in to comment.