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