@@ -105,10 +105,13 @@ protected function mutateFormData(array $data, callable $mutationStrategy): arra
105105 ['config ' => $ fieldConfig , 'instance ' => $ fieldInstance ] = $ this ->resolveFieldConfigAndInstance ($ field );
106106 $ data = $ mutationStrategy ($ field , $ fieldConfig , $ fieldInstance , $ data );
107107
108- if (! empty ($ field ->children )) {
109- foreach ($ field ->children as $ nestedField ) {
110- ['config ' => $ nestedFieldConfig , 'instance ' => $ nestedFieldInstance ] = $ this ->resolveFieldConfigAndInstance ($ nestedField );
111- $ data = $ mutationStrategy ($ nestedField , $ nestedFieldConfig , $ nestedFieldInstance , $ data );
108+ if ($ field ->field_type == Field::Builder->value ) {
109+ foreach ($ data [$ this ->record ->valueColumn ][$ field ->ulid ] as $ child ) {
110+ foreach ($ child ['data ' ] as $ ulid => $ value ) {
111+ $ field = Model::find ($ ulid );
112+ ['config ' => $ fieldConfig , 'instance ' => $ fieldInstance ] = $ this ->resolveFieldConfigAndInstance ($ field );
113+ $ data = $ mutationStrategy ($ field , $ fieldConfig , $ fieldInstance , $ data );
114+ }
112115 }
113116 }
114117 }
@@ -127,7 +130,7 @@ private function resolveFormFields(mixed $record = null, bool $isNested = false)
127130 $ customFields = $ this ->resolveCustomFields ();
128131
129132 return $ record ->fields
130- ->map (fn ($ field ) => $ this ->resolveFieldInput ($ field , $ customFields , $ record , $ isNested ))
133+ ->map (fn ($ field ) => $ this ->resolveFieldInput ($ field , $ customFields , $ record , $ isNested ))
131134 ->filter ()
132135 ->values ()
133136 ->all ();
@@ -136,7 +139,7 @@ private function resolveFormFields(mixed $record = null, bool $isNested = false)
136139 private function resolveCustomFields (): Collection
137140 {
138141 return collect (Fields::getFields ())
139- ->map (fn ($ fieldClass ) => new $ fieldClass );
142+ ->map (fn ($ fieldClass ) => new $ fieldClass );
140143 }
141144
142145 private function resolveFieldInput (Model $ field , Collection $ customFields , mixed $ record = null , bool $ isNested = false ): ?object
0 commit comments