/** * Add the UF Field. * * @param array $params * (reference) array containing the values submitted by the form. * * @return CRM_Core_BAO_UFField */ public static function add(&$params) { // set values for uf field properties and save $ufField = new CRM_Core_DAO_UFField(); $ufField->copyValues($params); $ufField->field_type = $params['field_name'][0]; $ufField->field_name = $params['field_name'][1]; //should not set location type id for Primary $locationTypeId = NULL; if ($params['field_name'][1] == 'url') { $ufField->website_type_id = CRM_Utils_Array::value(2, $params['field_name']); } else { $locationTypeId = CRM_Utils_Array::value(2, $params['field_name']); $ufField->website_type_id = NULL; } if ($locationTypeId) { $ufField->location_type_id = $locationTypeId; } else { $ufField->location_type_id = 'null'; } $ufField->phone_type_id = CRM_Utils_Array::value(3, $params['field_name'], 'NULL'); return $ufField->save(); }