3 * Test Generated example of using profile getfields API
4 * demonstrates retrieving profile fields passing in an id *
6 function profile_getfields_example(){
13 $result = civicrm_api3('profile', 'getfields', $params);
15 catch (CiviCRM_API3_Exception
$e) {
17 $errorMessage = $e->getMessage();
18 $errorCode = $e->getErrorCode();
19 $errorData = $e->getExtraParams();
20 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
27 * Function returns array of result expected from previous function
29 function profile_getfields_expectedresult(){
31 $expectedResult = array(
37 'label' => '_addCustomFieldToProfile',
38 'groupTitle' => '_addCustomFie',
39 'data_type' => 'String',
40 'html_type' => 'Text',
41 'default_value' => 'defaultValue',
43 'options_per_line' => '',
44 'custom_group_id' => '1',
45 'extends' => 'Contact',
46 'is_search_range' => 0,
47 'extends_entity_column_value' => '',
48 'extends_entity_column_id' => '',
51 'option_group_id' => '',
56 'api.required' => '1',
57 'title' => 'first_name',
60 'entity' => 'contact',
62 'api.aliases' => array(),
64 'postal_code-1' => array(
65 'name' => 'postal_code',
67 'title' => 'State Province',
71 'where' => 'civicrm_address.postal_code',
72 'headerPattern' => '/postal|zip/i',
73 'dataPattern' => '/\\d?\\d{4}(-\\d{4})?/',
78 'entity' => 'address',
80 'api.aliases' => array(),
82 'state_province-1' => array(
83 'name' => 'state_province_id',
85 'title' => 'State Province',
86 'FKClassName' => 'CRM_Core_DAO_StateProvince',
87 'pseudoconstant' => array(
88 'table' => 'civicrm_state_province',
90 'labelColumn' => 'name',
92 'api.required' => '1',
95 'entity' => 'address',
97 'api.aliases' => array(),
100 'name' => 'country_id',
102 'title' => 'Country',
103 'FKClassName' => 'CRM_Core_DAO_Country',
104 'pseudoconstant' => array(
105 'table' => 'civicrm_country',
107 'labelColumn' => 'name',
108 'nameColumn' => 'iso_code',
110 'api.required' => '1',
113 'entity' => 'address',
115 'api.aliases' => array(),
117 'phone-1-1' => array(
124 'where' => 'civicrm_phone.phone',
125 'headerPattern' => '/phone/i',
126 'dataPattern' => '/^[\\d\\(\\)\\-\\.\\s]+$/',
128 'api.required' => '1',
133 'api.aliases' => array(),
135 'email-primary' => array(
142 'where' => 'civicrm_email.email',
143 'headerPattern' => '/e.?mail/i',
144 'dataPattern' => '/^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$/',
147 'api.required' => '1',
152 'api.aliases' => array(
153 '0' => 'email-Primary',
156 'last_name' => array(
157 'name' => 'last_name',
159 'title' => 'Last Name',
163 'where' => 'civicrm_contact.last_name',
164 'headerPattern' => '/^last|(l(ast\\s)?name)$/i',
165 'dataPattern' => '/^\\w+(\\s\\w+)?+$/',
167 'api.required' => '1',
170 'entity' => 'contact',
172 'api.aliases' => array(),
174 'first_name' => array(
175 'name' => 'first_name',
177 'title' => 'First Name',
181 'where' => 'civicrm_contact.first_name',
182 'headerPattern' => '/^first|(f(irst\\s)?name)$/i',
183 'dataPattern' => '/^\\w+$/',
185 'api.required' => '1',
188 'entity' => 'contact',
190 'api.aliases' => array(),
192 'profile_id' => array(
193 'api.required' => true,
198 return $expectedResult;
203 * This example has been generated from the API test suite. The test that created it is called
205 * testGetFields and can be found in
206 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ProfileTest.php
208 * You can see the outcome of the API tests at
209 * http://tests.dev.civicrm.org/trunk/results-api_v3
211 * To Learn about the API read
212 * http://book.civicrm.org/developer/current/techniques/api/
214 * and review the wiki at
215 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
217 * Read more about testing here
218 * http://wiki.civicrm.org/confluence/display/CRM/Testing
220 * API Standards documentation:
221 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards