Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | |
3 | ||
4 | ||
5 | /* | |
1c88e578 | 6 | |
6a488035 TO |
7 | */ |
8 | function custom_field_create_example() { | |
9 | $params = array( | |
10 | 'custom_group_id' => 1, | |
11 | 'name' => 'test_date', | |
12 | 'label' => 'test_date', | |
13 | 'html_type' => 'Select Date', | |
14 | 'data_type' => 'Date', | |
15 | 'default_value' => '20071212', | |
16 | 'weight' => 4, | |
17 | 'is_required' => 1, | |
18 | 'is_searchable' => 0, | |
19 | 'is_active' => 1, | |
20 | 'version' => 3, | |
21 | ); | |
22 | ||
23 | require_once 'api/api.php'; | |
24 | $result = civicrm_api('custom_field', 'create', $params); | |
25 | ||
26 | return $result; | |
27 | } | |
28 | ||
29 | /* | |
30 | * Function returns array of result expected from previous function | |
31 | */ | |
32 | function custom_field_create_expectedresult() { | |
33 | ||
34 | $expectedResult = array( | |
35 | 'is_error' => 0, | |
36 | 'version' => 3, | |
37 | 'count' => 1, | |
38 | 'id' => 1, | |
39 | 'values' => array( | |
40 | '1' => array( | |
41 | 'id' => '1', | |
42 | 'custom_group_id' => '1', | |
43 | 'name' => 'test_date', | |
44 | 'label' => 'test_date', | |
45 | 'data_type' => 'Date', | |
46 | 'html_type' => 'Select Date', | |
47 | 'default_value' => '20071212', | |
48 | 'is_required' => '1', | |
49 | 'is_searchable' => 0, | |
50 | 'is_search_range' => 0, | |
51 | 'weight' => '4', | |
52 | 'help_pre' => '', | |
53 | 'help_post' => '', | |
54 | 'mask' => '', | |
55 | 'attributes' => '', | |
56 | 'javascript' => '', | |
57 | 'is_active' => '1', | |
58 | 'is_view' => 0, | |
59 | 'options_per_line' => '', | |
60 | 'text_length' => '', | |
61 | 'start_date_years' => '', | |
62 | 'end_date_years' => '', | |
63 | 'date_format' => '', | |
64 | 'time_format' => '', | |
65 | 'note_columns' => '', | |
66 | 'note_rows' => '', | |
67 | 'column_name' => 'test_date_1', | |
68 | 'option_group_id' => '', | |
69 | ), | |
70 | ), | |
71 | ); | |
72 | ||
73 | return $expectedResult; | |
74 | } | |
75 | ||
76 | ||
77 | ||
78 | ||
79 | /* | |
80 | * This example has been generated from the API test suite. The test that created it is called | |
1c88e578 | 81 | * custom_field_create |
82 | * You can see the outcome of the API tests at | |
6a488035 TO |
83 | * http://tests.dev.civicrm.org/trunk/results-api_v3 |
84 | * and review the wiki at | |
85 | * http://wiki.civicrm.org/confluence/display/CRMDOC40/CiviCRM+Public+APIs | |
86 | * Read more about testing here | |
87 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
88 | */ | |
89 |