Skip to content

Commit

Permalink
CustomField - switch statement to use data_type instead of html_type
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Apr 3, 2020
1 parent 467bdaa commit fdd43b2
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions CRM/Core/BAO/CustomGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -1316,10 +1316,10 @@ public static function setDefaults(&$groupTree, &$defaults, $viewMode = FALSE, $
}

$elementName = $field['element_name'];
$serialize = CRM_Core_BAO_CustomField::isSerialized($field);

switch ($field['html_type']) {
case 'Multi-Select':
case 'CheckBox':
if ($serialize) {
if ($field['data_type'] != 'Country' && $field['data_type'] != 'StateProvince') {
$defaults[$elementName] = [];
$customOption = CRM_Core_BAO_CustomOption::getCustomOption($field['id'], $inactiveNeeded);
if ($viewMode) {
Expand Down Expand Up @@ -1377,10 +1377,8 @@ public static function setDefaults(&$groupTree, &$defaults, $viewMode = FALSE, $
}
}
}
break;

case 'Multi-Select Country':
case 'Multi-Select State/Province':
}
else {
if (isset($value)) {
$checkedValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
foreach ($checkedValue as $val) {
Expand All @@ -1389,19 +1387,19 @@ public static function setDefaults(&$groupTree, &$defaults, $viewMode = FALSE, $
}
}
}
break;

case 'Select Country':
}
}
else {
if ($field['data_type'] == 'Country') {
if ($value) {
$defaults[$elementName] = $value;
}
else {
$config = CRM_Core_Config::singleton();
$defaults[$elementName] = $config->defaultContactCountry;
}
break;

default:
}
else {
if ($field['data_type'] == "Float") {
$defaults[$elementName] = (float) $value;
}
Expand All @@ -1413,6 +1411,7 @@ public static function setDefaults(&$groupTree, &$defaults, $viewMode = FALSE, $
else {
$defaults[$elementName] = $value;
}
}
}
}
}
Expand Down

0 comments on commit fdd43b2

Please sign in to comment.