$jsSet = TRUE;
}
else {
- $mappingHeader = $processor->getFieldName($i);
- $websiteTypeId = $processor->getWebsiteTypeID($i);
- $locationId = $processor->getLocationTypeID($i);
- $typeId = $processor->getPhoneOrIMTypeID($i);
-
- if ($websiteTypeId) {
- $defaults["mapper[$i]"] = [$mappingHeader, $websiteTypeId];
- }
- else {
- //default for IM/phone without related contact
- $defaults["mapper[$i]"] = [$mappingHeader ?? '', $locationId, $typeId];
- }
-
+ $defaults["mapper[$i]"] = $processor->getSavedQuickformDefaultsForColumn($i);
$js .= $processor->getQuickFormJSForField($i);
$jsSet = TRUE;
return implode("\n", $jsClauses) . "\n";
}
+ /**
+ * Get the defaults for the column from the saved mapping.
+ *
+ * @param int $column
+ *
+ * @return array
+ * @throws \CiviCRM_API3_Exception
+ */
+ public function getSavedQuickformDefaultsForColumn($column) {
+ if ($this->getWebsiteTypeID($column)) {
+ return [$this->getFieldName($column), $this->getWebsiteTypeID($column)];
+ }
+ return [(string) $this->getFieldName($column), $this->getLocationTypeID($column), $this->getPhoneOrIMTypeID($column)];
+ }
+
}