Skip to content

Commit d7a4b71

Browse files
committed
Fixing params that are not string
1 parent 28a6ab2 commit d7a4b71

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

Diff for: CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44

55
This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/).
66

7+
## [3.1.0]
8+
9+
### Removed
10+
11+
- `FD_FIELD_NAMES_TAGS` and `FD_FIELD_NAMES_FULL` constants.
12+
13+
### Changed
14+
15+
- backend logic for processing params that are array.
16+
717
## [3.0.18]
818

919
### Added
@@ -320,6 +330,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a
320330

321331
- Initial production release.
322332

333+
[3.1.0]: https://github.com/infinum/eightshift-forms-utils/compare/3.0.18...3.1.0
323334
[3.0.18]: https://github.com/infinum/eightshift-forms-utils/compare/3.0.17...3.0.18
324335
[3.0.17]: https://github.com/infinum/eightshift-forms-utils/compare/3.0.16...3.0.17
325336
[3.0.16]: https://github.com/infinum/eightshift-forms-utils/compare/3.0.15...3.0.16

Diff for: src/Config/UtilsConfig.php

-2
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,6 @@ class UtilsConfig
501501
public const FD_ICON = 'icon';
502502
public const FD_FIELDS = 'fields';
503503
public const FD_FIELD_NAMES = 'fieldNames';
504-
public const FD_FIELD_NAMES_TAGS = 'fieldNamesTags';
505-
public const FD_FIELD_NAMES_FULL = 'fieldNamesFull';
506504
public const FD_STEPS_SETUP = 'stepsSetup';
507505
public const FD_RESPONSE_OUTPUT_DATA = 'responseOutputData';
508506
public const FD_PARAMS_ORIGINAL = 'paramsOriginal';

Diff for: src/Helpers/UtilsGeneralHelper.php

-10
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,6 @@ public static function getFormDetails(string $formId): array
307307
UtilsConfig::FD_FIELDS => [],
308308
UtilsConfig::FD_FIELDS_ONLY => [],
309309
UtilsConfig::FD_FIELD_NAMES => [],
310-
UtilsConfig::FD_FIELD_NAMES_TAGS => [],
311-
UtilsConfig::FD_FIELD_NAMES_FULL => [],
312310
UtilsConfig::FD_STEPS_SETUP => [],
313311
];
314312

@@ -393,19 +391,11 @@ public static function getFormDetails(string $formId): array
393391
continue;
394392
}
395393

396-
$output[UtilsConfig::FD_FIELD_NAMES_FULL][] = $value;
397-
398394
if (isset($ignoreBlocks[$blockItemName])) {
399395
continue;
400396
}
401397

402398
$output[UtilsConfig::FD_FIELD_NAMES][] = $value;
403-
404-
if ($blockItemName === 'file') {
405-
continue;
406-
}
407-
408-
$output[UtilsConfig::FD_FIELD_NAMES_TAGS][] = $value;
409399
}
410400

411401
// Check if this form uses steps.

Diff for: src/Rest/Routes/AbstractUtilsBaseRoute.php

+22-21
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static function ($item) {
181181
);
182182

183183
// Append values to the first value.
184-
$innerNotEmpty[0]['value'] = \implode(UtilsConfig::DELIMITER, $multiple);
184+
$innerNotEmpty[0]['value'] = $multiple;
185185

186186
return $innerNotEmpty[0];
187187
}
@@ -304,17 +304,22 @@ static function ($item) {
304304

305305
// File.
306306
if ($fieldType === 'file') {
307-
$output['files'][$key] = $fieldValue ? \array_merge(
308-
$value,
309-
[
310-
'value' => \array_map(
311-
function ($item) {
312-
return UtilsUploadHelper::getFilePath($item);
313-
},
314-
\explode(UtilsConfig::DELIMITER, $fieldValue)
315-
),
316-
]
317-
) : $value;
307+
$output['files'][$key] = $value;
308+
309+
if (!$fieldValue) {
310+
$output['files'][$key]['value'] = [];
311+
} else {
312+
if (!\is_array($fieldValue)) {
313+
$fieldValue = [$fieldValue];
314+
}
315+
316+
$output['files'][$key]['value'] = \array_map(
317+
static function (string $file) {
318+
return UtilsUploadHelper::getFilePath($file);
319+
},
320+
$fieldValue
321+
);
322+
}
318323
break;
319324
}
320325

@@ -325,15 +330,13 @@ function ($item) {
325330

326331
// Checkbox.
327332
if ($fieldType === 'checkbox') {
328-
$fieldValue = \explode(UtilsConfig::DELIMITER, $fieldValue);
329-
}
330-
331-
// Select multiple.
332-
if ($fieldType === 'select' && \gettype($fieldValue) === 'array') {
333-
$value['value'] = \implode(UtilsConfig::DELIMITER, $fieldValue);
333+
if (!$fieldValue) {
334+
$value['value'] = [];
335+
} else {
336+
$value['value'] = \is_string($fieldValue) ? [$fieldValue] : $fieldValue;
337+
}
334338
}
335339

336-
$output['paramsRaw'][$fieldName] = $fieldValue;
337340
$output['params'][$key] = $value;
338341

339342
break;
@@ -471,8 +474,6 @@ protected function getFormDetailsApi($request): array
471474
$output[UtilsConfig::FD_FIELDS] = $formDetails[UtilsConfig::FD_FIELDS] ?? [];
472475
$output[UtilsConfig::FD_FIELDS_ONLY] = $formDetails[UtilsConfig::FD_FIELDS_ONLY] ?? [];
473476
$output[UtilsConfig::FD_FIELD_NAMES] = $formDetails[UtilsConfig::FD_FIELD_NAMES] ?? [];
474-
$output[UtilsConfig::FD_FIELD_NAMES_TAGS] = $formDetails[UtilsConfig::FD_FIELD_NAMES_TAGS] ?? [];
475-
$output[UtilsConfig::FD_FIELD_NAMES_FULL] = $formDetails[UtilsConfig::FD_FIELD_NAMES_FULL] ?? [];
476477
$output[UtilsConfig::FD_STEPS_SETUP] = $formDetails[UtilsConfig::FD_STEPS_SETUP] ?? [];
477478
}
478479

0 commit comments

Comments
 (0)