This repository was archived by the owner on Jan 2, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ private function setValue(
1919 $ inputName = static ::convertBracketsToDots ($ name );
2020
2121 if (!$ language ) {
22- $ default = $ this ->getBoundValue ($ bind , $ name ) ?: $ default ;
22+ $ boundValue = $ this ->getBoundValue ($ bind , $ name );
23+
24+ $ default = is_null ($ boundValue ) ? $ default : $ boundValue ;
2325
2426 return $ this ->value = old ($ inputName , $ default );
2527 }
Original file line number Diff line number Diff line change @@ -23,6 +23,15 @@ public function it_can_bind_a_target_to_the_form()
2323 ->seeElement ('input[name="radio"]:checked ' );
2424 }
2525
26+ /** @test */
27+ public function it_sets_the_right_value_if_the_value_is_zero ()
28+ {
29+ $ this ->registerTestRoute ('bind-target-zero-value ' );
30+
31+ $ this ->visit ('/bind-target-zero-value ' )
32+ ->seeElement ('input[name="input"][value="0"] ' );
33+ }
34+
2635 /** @test */
2736 public function it_overrides_the_bound_target_with_the_old_request_data ()
2837 {
Original file line number Diff line number Diff line change 1+ @php
2+ $target = [
3+ ' input' => 0 ,
4+ ];
5+ @endphp
6+
7+ <x-form >
8+ @bind ($target )
9+ <x-form-input name =" input" />
10+ <x-form-submit />
11+ @endbind
12+ </x-form >
You can’t perform that action at this time.
0 commit comments