Merge branch 'fix-list-person-custom-field' into 'master'

Fix "PersonList" with custom fields

See merge request Chill-Projet/chill-bundles!622
This commit is contained in:
Julien Fastré 2023-11-28 11:03:26 +00:00
commit 3d4c439be4
3 changed files with 13 additions and 3 deletions

View File

@ -0,0 +1,5 @@
kind: Fixed
body: 'Export: fix list person with custom fields'
time: 2023-11-27T21:01:38.260730706+01:00
custom:
Issue: ""

View File

@ -280,7 +280,7 @@ class CustomFieldChoice extends AbstractCustomField
$template = '@ChillCustomFields/CustomFieldsRendering/choice.html.twig';
if ('csv' === $documentType) {
$template = 'ChillCustomFieldsBundle/CustomFieldsRendering/choice.csv.twig';
$template = '@ChillCustomFields/CustomFieldsRendering/choice.csv.twig';
}
return $this->templating

View File

@ -332,7 +332,6 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
if (null === $value) {
return '';
}
$decoded = json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR);
if ('_header' === $value) {
$label = $cfType->getChoices($cf)[$slugChoice];
@ -341,6 +340,12 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
.' | '.$label;
}
try {
$decoded = json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
throw new \RuntimeException(sprintf('unable to decode json: %s, %s', json_last_error(), json_last_error_msg()), $e->getCode(), $e);
}
if ('_other' === $slugChoice && $cfType->isChecked($cf, $slugChoice, $decoded)) {
return $cfType->extractOtherValue($cf, $decoded);
}