CRM-16164 - Fix adding fields when reusing saved mapping
authorColeman Watts <coleman@civicrm.org>
Fri, 3 Apr 2015 01:31:27 +0000 (21:31 -0400)
committerColeman Watts <coleman@civicrm.org>
Fri, 3 Apr 2015 01:31:27 +0000 (21:31 -0400)
CRM/Export/Form/Map.php

index cc26bfbd605ba988dc5e98882b674aa19f33bfd1..4697e7295411ad1b29f2963d45bbd7701f0538a2 100644 (file)
@@ -66,14 +66,22 @@ class CRM_Export_Form_Map extends CRM_Core_Form {
    */
   public function preProcess() {
     $this->_exportColumnCount = $this->get('exportColumnCount');
+    $this->_mappingId = $this->get('mappingId');
+
     if (!$this->_exportColumnCount) {
-      $this->_exportColumnCount = 10;
+      // Set default from saved mapping
+      if ($this->_mappingId) {
+        $mapping = new CRM_Core_DAO_MappingField();
+        $mapping->mapping_id = $this->_mappingId;
+        $this->_exportColumnCount = $mapping->count();
+      }
+      else {
+        $this->_exportColumnCount = 10;
+      }
     }
     else {
-      $this->_exportColumnCount = $this->_exportColumnCount + 10;
+      $this->_exportColumnCount += 10;
     }
-
-    $this->_mappingId = $this->get('mappingId');
   }
 
   public function buildQuickForm() {