3 * Test Generated example of using custom_field create API
6 function custom_field_create_example(){
8 'custom_group_id' => 1,
9 'name' => 'test_textfield2',
11 'html_type' => 'Text',
12 'data_type' => 'String',
13 'default_value' => 'abc',
21 $result = civicrm_api3('custom_field', 'create', $params);
23 catch (CiviCRM_API3_Exception
$e) {
25 $errorMessage = $e->getMessage();
26 $errorCode = $e->getErrorCode();
27 $errorData = $e->getExtraParams();
28 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
35 * Function returns array of result expected from previous function
37 function custom_field_create_expectedresult(){
39 $expectedResult = array(
47 'custom_group_id' => '1',
48 'name' => 'test_textfield2',
50 'data_type' => 'String',
51 'html_type' => 'Text',
52 'default_value' => 'abc',
55 'is_search_range' => 0,
64 'options_per_line' => '',
66 'start_date_years' => '',
67 'end_date_years' => '',
72 'column_name' => 'name1_1',
73 'option_group_id' => '',
79 return $expectedResult;
84 * This example has been generated from the API test suite. The test that created it is called
86 * testCustomFieldCreateWithEdit and can be found in
87 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/CustomFieldTest.php
89 * You can see the outcome of the API tests at
90 * http://tests.dev.civicrm.org/trunk/results-api_v3
92 * To Learn about the API read
93 * http://book.civicrm.org/developer/current/techniques/api/
95 * and review the wiki at
96 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
98 * Read more about testing here
99 * http://wiki.civicrm.org/confluence/display/CRM/Testing
101 * API Standards documentation:
102 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards