Si vous constatez la perte de tickets, de commentaires ou de projets, veuillez consulter la page https://status.framasoft.org/incident/626.

Commit 4182c533 authored by Julien Fastré's avatar Julien Fastré

fix error when field definition has changed

parent 7568eb9e
Pipeline #127673 failed with stages
in 13 seconds
Master branch
=============
- fix error on export: error when field definition has changed
......@@ -361,6 +361,16 @@ class CustomFieldChoice extends AbstractCustomField
}
}
/**
* Return true if the choice given in $choiceSlug is checked inside $data.
*
* Used in list exports.
*
* @param CustomField $cf
* @param string $choiceSlug the slug of the choice we want to know if it was checked
* @param array|string $data the data of the field
* @return boolean
*/
public function isChecked(CustomField $cf, $choiceSlug, $data)
{
if ($data === null) {
......@@ -369,15 +379,15 @@ class CustomFieldChoice extends AbstractCustomField
if ($cf->getOptions()[self::MULTIPLE]) {
if ($cf->getOptions()[self::ALLOW_OTHER]) {
return \in_array($choiceSlug, $data['_choices']);
return \in_array($choiceSlug, $this->deserialize($data, $cf)['_choices']);
} else {
return \in_array($choiceSlug, $data);
return \in_array($choiceSlug, $this->deserialize($data, $cf));
}
} else {
if ($cf->getOptions()[self::ALLOW_OTHER]) {
return $data['_choices'] === $choiceSlug;
return $this->deserialize($data, $cf)['_choices'] === $choiceSlug;
} else {
return $data === $choiceSlug;
return $this->deserialize($data, $cf) === $choiceSlug;
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment