2121 */
2222abstract class ChoiceControl extends BaseControl
2323{
24+ /** @var bool[] */
25+ protected array $ disabledChoices = [];
2426 private bool $ checkDefaultValue = true ;
2527
2628 /** @var list<array{int|string, string|\Stringable}> */
@@ -77,7 +79,7 @@ public function setValue($value): static
7779 public function getValue (): mixed
7880 {
7981 return $ this ->value !== null
80- && !isset ($ this ->disabled [$ this ->value ])
82+ && !isset ($ this ->disabledChoices [$ this ->value ])
8183 && ([$ res ] = Arrays::first ($ this ->choices , fn ($ choice ) => $ choice [0 ] === $ this ->value ))
8284 ? $ res
8385 : null ;
@@ -130,7 +132,7 @@ public function getItems(): array
130132 public function getSelectedItem (): mixed
131133 {
132134 return $ this ->value !== null
133- && !isset ($ this ->disabled [$ this ->value ])
135+ && !isset ($ this ->disabledChoices [$ this ->value ])
134136 && ([, $ res ] = Arrays::first ($ this ->choices , fn ($ choice ) => $ choice [0 ] === $ this ->value ))
135137 ? $ res
136138 : null ;
@@ -143,12 +145,11 @@ public function getSelectedItem(): mixed
143145 public function setDisabled (bool |array $ value = true ): static
144146 {
145147 if (!is_array ($ value )) {
148+ $ this ->disabledChoices = [];
146149 return parent ::setDisabled ($ value );
147150 }
148-
149- parent ::setDisabled (false );
150- $ this ->disabled = array_fill_keys ($ value , value: true );
151- return $ this ;
151+ $ this ->disabledChoices = array_fill_keys ($ value , value: true );
152+ return parent ::setDisabled (false );
152153 }
153154
154155
0 commit comments