Fix for issue CRM-13089
authormmikitka <matt@mikitka.net>
Fri, 19 Jul 2013 23:46:17 +0000 (19:46 -0400)
committermmikitka <matt@mikitka.net>
Fri, 19 Jul 2013 23:46:17 +0000 (19:46 -0400)
----------------------------------------
* CRM-13089: CRM_Core_BAO_CustomField::create overrides user-defined name parameter values
  http://issues.civicrm.org/jira/browse/CRM-13089

CRM/Core/BAO/CustomField.php

index c2197f9d5be9419dcff75e47b6e0dc94bbf2c9af..77e306f909776fdc7c7a69663d24d45f5c6897a9 100644 (file)
@@ -130,14 +130,17 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
    * @static
    */
   static function create(&$params) {
-    if (!isset($params['id']) && !isset($params['column_name'])) {
-      // if add mode & column_name not present, calculate it.
-      $columnName = strtolower(CRM_Utils_String::munge($params['label'], '_', 32));
-
-      $params['name'] = CRM_Utils_String::munge($params['label'], '_', 64);
+    if (!isset($params['id'])) {
+      if (!isset($params['column_name'])) {
+        // if add mode & column_name not present, calculate it.
+        $params['column_name'] = strtolower(CRM_Utils_String::munge($params['label'], '_', 32));
+      }
+      if (!isset($params['name'])) {
+        $params['name'] = CRM_Utils_String::munge($params['label'], '_', 64);
+      }
     }
-    elseif (isset($params['id'])) {
-      $columnName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField',
+    else {
+      $params['column_name'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField',
         $params['id'],
         'column_name'
       );