CRM-13072 Update examples
[civicrm-core.git] / api / v3 / examples / UFFieldCreate.php
index 1b374826d10952bf0b1d60ba167b48fb84722b78..1c7350982dca11acf53c0c5e905b2dba7222b2fd 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using uf_field create API
+ * *
  */
 function uf_field_create_example(){
 $params = array(
@@ -14,16 +14,24 @@ $params = array(
   'is_active' => 1,
   'location_type_id' => 1,
   'phone_type_id' => 1,
-  'version' => 3,
   'uf_group_id' => 11,
 );
 
-  $result = civicrm_api( 'uf_field','create',$params );
+try{
+  $result = civicrm_api3('uf_field', 'create', $params);
+}
+catch (CiviCRM_API3_Exception $e) {
+  // handle error here
+  $errorMessage = $e->getMessage();
+  $errorCode = $e->getErrorCode();
+  $errorData = $e->getExtraParams();
+  return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function uf_field_create_expectedresult(){
@@ -57,7 +65,7 @@ function uf_field_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }