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(
36 'first_name' => array(
37 'name' => 'first_name',
39 'title' => 'First Name',
43 'where' => 'civicrm_contact.first_name',
44 'headerPattern' => '/^first|(f(irst\s)?name)$/i',
45 'dataPattern' => '/^\w+$/',
49 'name' => 'last_name',
51 'title' => 'Last Name',
55 'where' => 'civicrm_contact.last_name',
56 'headerPattern' => '/^last|(l(ast\s)?name)$/i',
57 'dataPattern' => '/^\w+(\s\w+)?+$/',
67 'where' => 'civicrm_email.email',
68 'headerPattern' => '/e.?mail/i',
69 '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]$/',
81 'where' => 'civicrm_phone.phone',
82 'headerPattern' => '/phone/i',
83 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
88 'name' => 'country_id',
91 'FKClassName' => 'CRM_Core_DAO_Country',
92 'pseudoconstant' => array(
93 'table' => 'civicrm_country',
95 'labelColumn' => 'name',
96 'nameColumn' => 'iso_code',
99 'state_province-1' => array(
100 'name' => 'state_province_id',
103 'FKClassName' => 'CRM_Core_DAO_StateProvince',
104 'pseudoconstant' => array(
105 'table' => 'civicrm_state_province',
107 'labelColumn' => 'name',
110 'postal_code-1' => array(
111 'name' => 'postal_code',
113 'title' => 'Postal Code',
117 'where' => 'civicrm_address.postal_code',
118 'headerPattern' => '/postal|zip/i',
119 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
123 'label' => '_addCustomFieldToProfile',
124 'groupTitle' => '_addCustomFie',
125 'data_type' => 'String',
126 'html_type' => 'Text',
127 'default_value' => 'defaultValue',
129 'options_per_line' => '',
130 'custom_group_id' => '1',
131 'extends' => 'Contact',
132 'is_search_range' => 0,
133 'extends_entity_column_value' => '',
134 'extends_entity_column_id' => '',
137 'option_group_id' => '',
140 'name' => 'custom_1',
143 'profile_id' => array(
144 'api.required' => true,
149 return $expectedResult;
154 * This example has been generated from the API test suite. The test that created it is called
156 * testGetFields and can be found in
157 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ProfileTest.php
159 * You can see the outcome of the API tests at
160 * http://tests.dev.civicrm.org/trunk/results-api_v3
162 * To Learn about the API read
163 * http://book.civicrm.org/developer/current/techniques/api/
165 * and review the wiki at
166 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
168 * Read more about testing here
169 * http://wiki.civicrm.org/confluence/display/CRM/Testing
171 * API Standards documentation:
172 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards