Skip to content

Commit

Permalink
Fix dedupe screen to always set the checkbox to 'ticked' where data w…
Browse files Browse the repository at this point in the history
…ould otherwise be lost

Full details are here civicrm#15595 - although this does not include the
cleanup commits I did getting to this point.

Bug: T235450
Change-Id: I60d93df0ee3d34ff5c3b7b7c7e5034aafbdfd740
  • Loading branch information
eileenmcnaughton committed Jan 7, 2020
1 parent 55e2db1 commit c794564
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 4 additions & 1 deletion CRM/Contact/Form/Merge.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,16 @@ public function preProcess() {
// @todo consider enabling if it is an add & defaulting to true.
$element[4] = array_merge((array) CRM_Utils_Array::value(4, $element, []), ['disabled' => TRUE]);
}
$this->addElement($element[0],
$newCheckBox = $this->addElement($element[0],
$element[1],
array_key_exists('2', $element) ? $element[2] : NULL,
array_key_exists('3', $element) ? $element[3] : NULL,
array_key_exists('4', $element) ? $element[4] : NULL,
array_key_exists('5', $element) ? $element[5] : NULL
);
if (!empty($element['is_checked'])) {
$newCheckBox->setChecked(TRUE);
}
}

// add related table elements
Expand Down
13 changes: 7 additions & 6 deletions CRM/Dedupe/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -1138,12 +1138,13 @@ public static function getRowsElementsAndInfo($mainId, $otherId, $checkPermissio
// Display a checkbox to migrate, only if the values are different
if ($value != $main[$field]) {
$elements[] = [
'advcheckbox',
"move_$field",
NULL,
NULL,
NULL,
$value,
0 => 'advcheckbox',
1 => "move_$field",
2 => NULL,
3 => NULL,
4 => NULL,
5 => $value,
'is_checked' => (!isset($main[$field]) || $main[$field] === ''),
];
}

Expand Down

0 comments on commit c794564

Please sign in to comment.