@@ -131,6 +131,19 @@ public function init(): void
131131 $ event ->value = $ event ->rawValue ;
132132 }
133133 }
134+
135+ if ($ event ->integrationField ->sourceType === 'file ' && $ event ->integration ->mapToForm ) {
136+ // For HubSpot File fields, we need to handle content differently
137+ if (is_string ($ event ->value )) {
138+ $ event ->value = array_map ('trim ' , explode (', ' , $ event ->value ));
139+ }
140+
141+ // Let our form-field processing handling know about it needs to be treated differently
142+ // Prevent changing multiple times, as this event is called
143+ if (is_array ($ event ->value ) && !isset ($ event ->value ['FILE_UPLOAD_DATA ' ])) {
144+ $ event ->value = ['FILE_UPLOAD_DATA ' => $ event ->value ];
145+ }
146+ }
134147 });
135148 }
136149
@@ -566,11 +579,22 @@ public function sendPayload(Submission $submission): bool
566579 $ handleParts = explode ('. ' , $ key );
567580 $ objectTypeId = str_replace (['CONTACT ' , 'COMPANY ' ], ['0-1 ' , '0-2 ' ], ($ handleParts [0 ] ?? 'CONTACT ' ));
568581
569- $ formPayload ['fields ' ][] = [
570- 'objectTypeId ' => $ objectTypeId ,
571- 'name ' => $ handleParts [1 ] ?? '' ,
572- 'value ' => $ value ,
573- ];
582+ // Special-handling for some fields.
583+ if (is_array ($ value ) && isset ($ value ['FILE_UPLOAD_DATA ' ])) {
584+ foreach ($ value ['FILE_UPLOAD_DATA ' ] as $ subValue ) {
585+ $ formPayload ['fields ' ][] = [
586+ 'objectTypeId ' => $ objectTypeId ,
587+ 'name ' => $ handleParts [1 ] ?? '' ,
588+ 'value ' => $ subValue ,
589+ ];
590+ }
591+ } else {
592+ $ formPayload ['fields ' ][] = [
593+ 'objectTypeId ' => $ objectTypeId ,
594+ 'name ' => $ handleParts [1 ] ?? '' ,
595+ 'value ' => $ value ,
596+ ];
597+ }
574598 }
575599
576600 // Setup Hubspot's context, if we're mapping it, or if it's automatically saved in context
0 commit comments