- case 'Select':
- if (is_array($value)) {
- $display = NULL;
- foreach ($value as $data) {
- $display .= $display ? ', ' . $option[$data] : $option[$data];
- }
- }
- else {
- $display = CRM_Utils_Array::value($value, $option);
- }
- break;
+ if ($data_type == 'StateProvince') {
+ $option = CRM_Core_PseudoConstant::stateProvince(FALSE, FALSE);
+ }
+
+ $field = array(
+ 'id' => $fieldID,
+ 'html_type' => $html_type,
+ 'data_type' => $data_type,
+ 'options' => $option,
+ );
+
+ return self::formatDisplayValue($value, $field, $contactID);
+ }
+
+
+ /**
+ * Lower-level logic for rendering a custom field value
+ *
+ * @param string|array $value
+ * @param array $field
+ * @param int|null $contactID
+ *
+ * @return string|array|int|null
+ */
+ private static function formatDisplayValue($value, $field, $contactID = NULL) {
+ $display = $value;
+
+ if (self::isSerialized($field) && !is_array($value)) {
+ $value = (array) CRM_Utils_Array::explodePadded($value);
+ }
+ // CRM-12989 fix
+ if ($field['html_type'] == 'CheckBox') {
+ CRM_Utils_Array::formatArrayKeys($value);
+ }
+
+ switch ($field['html_type']) {