PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Common / Helpers / Import / GravityFormsAddressFieldMapper.php

GravityFormsAddressFieldMapper.php in The Innovative Form Builder – IvyForms 1.5, at backend/src/Common/Helpers/Import/GravityFormsAddressFieldMapper.php

58 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Common\Helpers\Import;
4
5 /**
6 * Map a Gravity Forms address field and its visible inputs.
7 */
8 class GravityFormsAddressFieldMapper
9 {
10 /**
11 * @param array<string, mixed> $rawField
12 * @param array<int, array<string, mixed>> $fields
13 * @param array<string, int> $context
14 * @return void
15 */
16 public static function append(array $rawField, array &$fields, array &$context): void
17 {
18 $typeMap = [
19 '1' => 'streetAddress',
20 '2' => 'addressLine2',
21 '3' => 'city',
22 '4' => 'state',
23 '5' => 'zip',
24 '6' => 'country',
25 ];
26 $parts = [];
27
28 foreach (($rawField['inputs'] ?? []) as $input) {
29 if (!is_array($input)) {
30 continue;
31 }
32
33 $inputIdParts = explode('.', (string) ($input['id'] ?? ''));
34 $suffix = (string) end($inputIdParts);
35 if (!isset($typeMap[$suffix])) {
36 continue;
37 }
38
39 $parts[] = [
40 'type' => $typeMap[$suffix],
41 'label' => $input['label'] ?? '',
42 'placeholder' => $input['placeholder'] ?? '',
43 'defaultValue' => $input['defaultValue'] ?? '',
44 'visible' => empty($input['isHidden']),
45 ];
46 }
47
48 ThirdPartyAddressFieldMapper::append(
49 (string) ($rawField['label'] ?? ''),
50 (string) ($rawField['description'] ?? ''),
51 !empty($rawField['isRequired']),
52 $parts,
53 $fields,
54 $context
55 );
56 }
57 }
58