diff --git a/src/fields/formfields/Recipients.php b/src/fields/formfields/Recipients.php index d10bfe9e7..a36f763ff 100644 --- a/src/fields/formfields/Recipients.php +++ b/src/fields/formfields/Recipients.php @@ -43,6 +43,15 @@ public static function getSvgIconPath(): string return 'formie/_formfields/recipients/icon.svg'; } + /** + * Returns whether a string value looks like a JSON object or array. + * TODO: Remove this when bumping to 3.5+ + */ + public static function isJsonObject(string $str): bool + { + return (bool)preg_match('/^(?:\{.*\}|\[.*\])$/s', $str); + } + // Public Methods // ========================================================================= @@ -69,7 +78,7 @@ public function getIsFieldset(): bool public function normalizeValue($value, ElementInterface $element = null) { // Sort out multiple options being set - if (is_string($value) && Json::isJsonObject($value)) { + if (is_string($value) && self::isJsonObject($value)) { $value = implode(',', array_filter(Json::decode($value))); } @@ -281,7 +290,7 @@ private function _getRealValue($value) $value = StringHelper::decdec($value); // Check if this was an array of data - if (is_string($value) && Json::isJsonObject($value)) { + if (is_string($value) && self::isJsonObject($value)) { $value = implode(',', array_filter(Json::decode($value))); } }