+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018 |
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
*/
/**
case 'Multi-Select State/Province':
case 'Multi-Select Country':
if ($field['data_type'] == 'ContactReference' && $value) {
- $display = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $value, 'display_name');
+ if (is_numeric($value)) {
+ $display = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $value, 'display_name');
+ }
+ else {
+ $display = $value;
+ }
}
elseif (is_array($value)) {
$v = array();
case 'Text':
if ($field['data_type'] == 'Money' && isset($value)) {
- //$value can also be an array(while using IN operator from search builder or api).
+ // $value can also be an array(while using IN operator from search builder or api).
foreach ((array) $value as $val) {
$disp[] = CRM_Utils_Money::format($val, NULL, NULL, TRUE);
}
return $isMultipleWithGid;
}
+ /**
+ * Does this field type have any select options?
+ *
+ * @param array $field
+ *
+ * @return bool
+ */
+ public static function hasOptions($field) {
+ // Fields retrieved via api are an array, or from the dao are an object. We'll accept either.
+ $field = (array) $field;
+ // This will include boolean fields with Yes/No options.
+ if (in_array($field['html_type'], ['Radio', 'CheckBox'])) {
+ return TRUE;
+ }
+ // Do this before the "Select" string search because date fields have a "Select Date" html_type
+ // and contactRef fields have an "Autocomplete-Select" html_type - contacts are an FK not an option list.
+ if (in_array($field['data_type'], ['ContactReference', 'Date'])) {
+ return FALSE;
+ }
+ if (strpos($field['html_type'], 'Select') !== FALSE) {
+ return TRUE;
+ }
+ return !empty($field['option_group_id']);
+ }
+
/**
* Does this field store a serialized string?
*