use number wiget for weight fields in all forms
[civicrm-core.git] / CRM / UF / Form / Field.php
index 82c96c68032d4666ff195717958b5191a25d86c9..5b0c433a781ccc1bab69f472baba9d2c76a22b3d 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
  */
 
 /**
@@ -439,7 +439,7 @@ class CRM_UF_Form_Field extends CRM_Core_Form {
     $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField');
 
     // weight
-    $this->add('text', 'weight', ts('Order'), $attributes['weight'], TRUE);
+    $this->add('number', 'weight', ts('Order'), $attributes['weight'], TRUE);
     $this->addRule('weight', ts('is a numeric field'), 'numeric');
 
     $this->add('textarea', 'help_pre', ts('Field Pre Help'), $attributes['help_pre']);
@@ -551,6 +551,10 @@ class CRM_UF_Form_Field extends CRM_Core_Form {
         $apiFormattedParams['location_type_id'] = $params['field_name'][2];
       }
     }
+    elseif ($params['field_name'][2] == 0) {
+      // 0 is Primary location type
+      $apiFormattedParams['location_type_id'] = NULL;
+    }
     if (!empty($params['field_name'][3])) {
       $apiFormattedParams['phone_type_id'] = $params['field_name'][3];
     }