File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -31,14 +31,21 @@ public function mountedFields(Collection $fields): void
3131
3232 public function updatedFields (mixed $ value , string $ key ): void
3333 {
34- $ this ->validateOnly ("fields. {$ key }" );
34+ /**
35+ * When handling array fields like checkboxes, the $key can look like "services.value.0".
36+ * This can cause issues with validation, since it targets a specific item instead of the whole array.
37+ * The following code fixes this by pointing the $key to the full array "services.value" instead.
38+ */
39+ $ key = str ($ key )->explode ('. ' )->slice (0 , 2 )->prepend ('fields ' )->join ('. ' );
40+
41+ $ this ->validateOnly ($ key );
3542
3643 /**
3744 * Explicitly forget the errors of this field after validation has passed
3845 * so that we don't restore them in some edge case scenarios.
3946 */
4047 if ($ this ->isWizardForm ()) {
41- $ this ->resetStepErrorBag (" fields. { $ key}" );
48+ $ this ->resetStepErrorBag ($ key );
4249 }
4350 }
4451
You can’t perform that action at this time.
0 commit comments