Skip to content

Commit

Permalink
CustomField code cleanup to use isSerialized method
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Apr 7, 2020
1 parent a486eec commit c54649b
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions CRM/Core/BAO/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -1440,19 +1440,11 @@ public static function formatCustomField(
}
}
}

if ($customFields[$customFieldId]['html_type'] == 'Multi-Select') {
if ($value) {
$value = CRM_Utils_Array::implodePadded($value);
}
else {
$value = '';
}
elseif (self::isSerialized($customFields[$customFieldId])) {
$value = $value ? CRM_Utils_Array::implodePadded($value) : '';
}

if (($customFields[$customFieldId]['html_type'] == 'Multi-Select' ||
$customFields[$customFieldId]['html_type'] == 'CheckBox'
) &&
if (self::isSerialized($customFields[$customFieldId]) &&
$customFields[$customFieldId]['data_type'] == 'String' &&
!empty($customFields[$customFieldId]['text_length']) &&
!empty($value)
Expand Down Expand Up @@ -2616,20 +2608,17 @@ protected static function prepareCreateParams($field, $operation) {
}
$params['fkName'] = $fkName;
}
if ($field->data_type == 'Country' && $field->html_type == 'Select Country') {
if ($field->data_type == 'Country' && !self::isSerialized($field)) {
$params['fk_table_name'] = 'civicrm_country';
$params['fk_field_name'] = 'id';
$params['fk_attributes'] = 'ON DELETE SET NULL';
}
elseif ($field->data_type == 'Country' && $field->html_type == 'Multi-Select Country') {
$params['type'] = 'varchar(255)';
}
elseif ($field->data_type == 'StateProvince' && $field->html_type == 'Select State/Province') {
elseif ($field->data_type == 'StateProvince' && !self::isSerialized($field)) {
$params['fk_table_name'] = 'civicrm_state_province';
$params['fk_field_name'] = 'id';
$params['fk_attributes'] = 'ON DELETE SET NULL';
}
elseif ($field->data_type == 'StateProvince' && $field->html_type == 'Multi-Select State/Province') {
elseif ($field->data_type == 'StateProvince' || $field->data_type == 'Country') {
$params['type'] = 'varchar(255)';
}
elseif ($field->data_type == 'File') {
Expand Down

0 comments on commit c54649b

Please sign in to comment.