diff --git a/modules/redcap/php/client/models/redcapdictionaryrecord.class.inc b/modules/redcap/php/client/models/redcapdictionaryrecord.class.inc index e3062f3899f..c550db9b54f 100644 --- a/modules/redcap/php/client/models/redcapdictionaryrecord.class.inc +++ b/modules/redcap/php/client/models/redcapdictionaryrecord.class.inc @@ -313,17 +313,30 @@ class RedcapDictionaryRecord $choices = explode('|', $dictionary); $linstChoices = []; - $pattern = "/^(\s)*([[:alnum:]]+)(\s)*,(.*)$/"; + $pattern = "/^(\s)*([[:alnum:]._]+)(\s)*,(.*)$/"; + + $index = 1; //Auto-index counter foreach ($choices as $choice) { + $choice = trim($choice); + $matches = []; + if (preg_match($pattern, $choice, $matches) !== 1) { - throw new \DomainException( - "Could not parse radio option: '$choice'" + // Missing code -auto-generate one + error_log( + "Warning: Auto-indexing malformed option: + '$choice' as index $index" ); - + $backend = $index; + $label = $choice; + $index++; + } else { + //Normal parsing + $backend = $matches[2]; + $label = trim($matches[4]); } - $backend = $matches[2]; - $linstFormat = "'$backend'=>'" . trim($matches[4]) . '\''; + + $linstFormat = "'$backend'=>'$label'"; $linstChoices[] = $linstFormat; }