CRM-13209, image url should not be required if already set
authorkurund <kurund@civicrm.org>
Tue, 27 Aug 2013 20:10:10 +0000 (01:40 +0530)
committerkurund <kurund@civicrm.org>
Tue, 27 Aug 2013 20:10:10 +0000 (01:40 +0530)
----------------------------------------
* CRM-13209: Mandatory custom fields, on edit, always require a new upload (regression)
  http://issues.civicrm.org/jira/browse/CRM-13209

CRM/Profile/Form.php

index 5db324da76aa45708d14fb2fac9182280a5d96cd..4a083cc8c51153704c1d3bb974d02bc62dbd8fa1 100644 (file)
@@ -505,7 +505,8 @@ class CRM_Profile_Form extends CRM_Core_Form {
           }
         }
       }
-    } else {
+    }
+    else {
       foreach ($this->_fields as $name => $field) {
         if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
           $htmlType = $field['html_type'];
@@ -522,9 +523,7 @@ class CRM_Profile_Form extends CRM_Core_Form {
 
           if ($htmlType == 'File') {
             $entityId = $this->_id;
-            if (CRM_Utils_Array::value('field_type', $field) == 'Activity' &&
-              $this->_activityId
-            ) {
+            if (CRM_Utils_Array::value('field_type', $field) == 'Activity' && $this->_activityId) {
               $entityId = $this->_activityId;
             }
             $url = CRM_Core_BAO_CustomField::getFileURL($entityId, $customFieldID);
@@ -564,6 +563,7 @@ class CRM_Profile_Form extends CRM_Core_Form {
       $this->assign("imageThumbWidth", $imageThumbWidth);
       $this->assign("imageThumbHeight", $imageThumbHeight);
       $this->assign("imageURL", $this->_defaults['image_URL']);
+      $this->removeFileRequiredRules('image_URL');
     }
 
     if (array_key_exists('contact_sub_type', $this->_defaults) &&