Merge pull request #11736 from jitendrapurohit/CRM-21815
[civicrm-core.git] / api / v3 / examples / Contact / GetFieldsOptions.php
CommitLineData
6a488035 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the Contact.getfields API.
50fb255d 4 *
5c49fee0 5 * Demonstrates retrieving metadata with custom field options.
50fb255d 6 *
7 * @return array
8 * API result array
9 */
10function contact_getfields_example() {
11 $params = array(
12 'options' => array(
6a488035
TO
13 'get_options' => 'custom_1',
14 ),
50fb255d 15 'action' => 'create',
16 );
6a488035 17
50fb255d 18 try{
a828d7b8 19 $result = civicrm_api3('Contact', 'getfields', $params);
50fb255d 20 }
21 catch (CiviCRM_API3_Exception $e) {
22 // Handle error here.
23 $errorMessage = $e->getMessage();
24 $errorCode = $e->getErrorCode();
25 $errorData = $e->getExtraParams();
26 return array(
5be22f39 27 'is_error' => 1,
28 'error_message' => $errorMessage,
50fb255d 29 'error_code' => $errorCode,
30 'error_data' => $errorData,
31 );
32 }
6a488035 33
50fb255d 34 return $result;
6a488035
TO
35}
36
fb32de45 37/**
50fb255d 38 * Function returns array of result expected from previous function.
39 *
40 * @return array
41 * API result array
6a488035 42 */
50fb255d 43function contact_getfields_expectedresult() {
6a488035 44
7a7cc10b 45 $expectedResult = array(
50fb255d 46 'is_error' => 0,
47 'version' => 3,
48 'count' => 55,
49 'values' => array(
7a7cc10b 50 'id' => array(
50fb255d 51 'name' => 'id',
52 'type' => 1,
5be22f39 53 'title' => 'Contact ID',
54 'description' => 'Unique Contact ID',
50fb255d 55 'required' => TRUE,
56 'import' => TRUE,
57 'where' => 'civicrm_contact.id',
58 'headerPattern' => '/internal|contact?|id$/i',
59 'export' => TRUE,
1d8ee3d6 60 'table_name' => 'civicrm_contact',
61 'entity' => 'Contact',
62 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 63 'api.aliases' => array(
64 '0' => 'contact_id',
65 ),
66 ),
7a7cc10b 67 'contact_type' => array(
50fb255d 68 'name' => 'contact_type',
69 'type' => 2,
70 'title' => 'Contact Type',
5be22f39 71 'description' => 'Type of Contact.',
50fb255d 72 'maxlength' => 64,
73 'size' => 30,
74 'export' => TRUE,
75 'where' => 'civicrm_contact.contact_type',
1d8ee3d6 76 'table_name' => 'civicrm_contact',
77 'entity' => 'Contact',
78 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 79 'html' => array(
80 'type' => 'Select',
5be22f39 81 'maxlength' => 64,
82 'size' => 30,
50fb255d 83 ),
84 'pseudoconstant' => array(
85 'table' => 'civicrm_contact_type',
86 'keyColumn' => 'name',
87 'labelColumn' => 'label',
88 'condition' => 'parent_id IS NULL',
89 ),
90 'api.required' => 1,
91 ),
7a7cc10b 92 'contact_sub_type' => array(
50fb255d 93 'name' => 'contact_sub_type',
94 'type' => 2,
95 'title' => 'Contact Subtype',
5be22f39 96 'description' => 'May be used to over-ride contact view and edit templates.',
50fb255d 97 'maxlength' => 255,
98 'size' => 45,
99 'import' => TRUE,
100 'where' => 'civicrm_contact.contact_sub_type',
101 'headerPattern' => '/C(ontact )?(subtype|sub-type|sub type)/i',
102 'export' => TRUE,
1d8ee3d6 103 'table_name' => 'civicrm_contact',
104 'entity' => 'Contact',
105 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 106 'html' => array(
5be22f39 107 'type' => 'Select',
108 'maxlength' => 255,
109 'size' => 45,
50fb255d 110 ),
111 'pseudoconstant' => array(
112 'table' => 'civicrm_contact_type',
113 'keyColumn' => 'name',
114 'labelColumn' => 'label',
115 'condition' => 'parent_id IS NOT NULL',
116 ),
117 ),
7a7cc10b 118 'do_not_email' => array(
50fb255d 119 'name' => 'do_not_email',
120 'type' => 16,
121 'title' => 'Do Not Email',
122 'import' => TRUE,
123 'where' => 'civicrm_contact.do_not_email',
124 'headerPattern' => '/d(o )?(not )?(email)/i',
125 'dataPattern' => '/^\\d{1,}$/',
126 'export' => TRUE,
1d8ee3d6 127 'table_name' => 'civicrm_contact',
128 'entity' => 'Contact',
129 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 130 'html' => array(
131 'type' => 'CheckBox',
132 ),
133 ),
7a7cc10b 134 'do_not_phone' => array(
50fb255d 135 'name' => 'do_not_phone',
136 'type' => 16,
137 'title' => 'Do Not Phone',
138 'import' => TRUE,
139 'where' => 'civicrm_contact.do_not_phone',
140 'headerPattern' => '/d(o )?(not )?(call|phone)/i',
141 'dataPattern' => '/^\\d{1,}$/',
142 'export' => TRUE,
1d8ee3d6 143 'table_name' => 'civicrm_contact',
144 'entity' => 'Contact',
145 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 146 'html' => array(
147 'type' => 'CheckBox',
148 ),
149 ),
7a7cc10b 150 'do_not_mail' => array(
50fb255d 151 'name' => 'do_not_mail',
152 'type' => 16,
153 'title' => 'Do Not Mail',
154 'import' => TRUE,
155 'where' => 'civicrm_contact.do_not_mail',
156 'headerPattern' => '/^(d(o\\s)?n(ot\\s)?mail)|(\\w*)?bulk\\s?(\\w*)$/i',
157 'dataPattern' => '/^\\d{1,}$/',
158 'export' => TRUE,
1d8ee3d6 159 'table_name' => 'civicrm_contact',
160 'entity' => 'Contact',
161 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 162 'html' => array(
163 'type' => 'CheckBox',
164 ),
165 ),
7a7cc10b 166 'do_not_sms' => array(
50fb255d 167 'name' => 'do_not_sms',
168 'type' => 16,
169 'title' => 'Do Not Sms',
170 'import' => TRUE,
171 'where' => 'civicrm_contact.do_not_sms',
172 'headerPattern' => '/d(o )?(not )?(sms)/i',
173 'dataPattern' => '/^\\d{1,}$/',
174 'export' => TRUE,
1d8ee3d6 175 'table_name' => 'civicrm_contact',
176 'entity' => 'Contact',
177 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 178 'html' => array(
179 'type' => 'CheckBox',
180 ),
181 ),
7a7cc10b 182 'do_not_trade' => array(
50fb255d 183 'name' => 'do_not_trade',
184 'type' => 16,
185 'title' => 'Do Not Trade',
186 'import' => TRUE,
187 'where' => 'civicrm_contact.do_not_trade',
188 'headerPattern' => '/d(o )?(not )?(trade)/i',
189 'dataPattern' => '/^\\d{1,}$/',
190 'export' => TRUE,
1d8ee3d6 191 'table_name' => 'civicrm_contact',
192 'entity' => 'Contact',
193 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 194 'html' => array(
195 'type' => 'CheckBox',
196 ),
197 ),
7a7cc10b 198 'is_opt_out' => array(
50fb255d 199 'name' => 'is_opt_out',
200 'type' => 16,
201 'title' => 'No Bulk Emails (User Opt Out)',
5be22f39 202 'description' => 'Has the contact opted out from receiving all bulk email from the organization or site domain?',
50fb255d 203 'required' => TRUE,
204 'import' => TRUE,
205 'where' => 'civicrm_contact.is_opt_out',
206 'export' => TRUE,
1d8ee3d6 207 'table_name' => 'civicrm_contact',
208 'entity' => 'Contact',
209 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 210 'html' => array(
211 'type' => 'CheckBox',
212 ),
213 ),
7a7cc10b 214 'legal_identifier' => array(
50fb255d 215 'name' => 'legal_identifier',
216 'type' => 2,
217 'title' => 'Legal Identifier',
5be22f39 218 'description' => 'May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.
219 ',
50fb255d 220 'maxlength' => 32,
221 'size' => 20,
222 'import' => TRUE,
223 'where' => 'civicrm_contact.legal_identifier',
224 'headerPattern' => '/legal\\s?id/i',
225 'dataPattern' => '/\\w+?\\d{5,}/',
226 'export' => TRUE,
1d8ee3d6 227 'table_name' => 'civicrm_contact',
228 'entity' => 'Contact',
229 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 230 'html' => array(
231 'type' => 'Text',
5be22f39 232 'maxlength' => 32,
233 'size' => 20,
50fb255d 234 ),
235 ),
7a7cc10b 236 'external_identifier' => array(
50fb255d 237 'name' => 'external_identifier',
238 'type' => 2,
239 'title' => 'External Identifier',
5be22f39 240 'description' => 'Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.',
5c49fee0 241 'maxlength' => 64,
50fb255d 242 'size' => 8,
243 'import' => TRUE,
244 'where' => 'civicrm_contact.external_identifier',
245 'headerPattern' => '/external\\s?id/i',
246 'dataPattern' => '/^\\d{11,}$/',
247 'export' => TRUE,
1d8ee3d6 248 'table_name' => 'civicrm_contact',
249 'entity' => 'Contact',
250 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 251 'html' => array(
252 'type' => 'Text',
5be22f39 253 'maxlength' => 64,
254 'size' => 8,
50fb255d 255 ),
256 ),
7a7cc10b 257 'sort_name' => array(
50fb255d 258 'name' => 'sort_name',
259 'type' => 2,
260 'title' => 'Sort Name',
5be22f39 261 'description' => 'Name used for sorting different contact types',
50fb255d 262 'maxlength' => 128,
263 'size' => 30,
264 'export' => TRUE,
265 'where' => 'civicrm_contact.sort_name',
1d8ee3d6 266 'table_name' => 'civicrm_contact',
267 'entity' => 'Contact',
268 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 269 'html' => array(
270 'type' => 'Text',
5be22f39 271 'maxlength' => 128,
272 'size' => 30,
50fb255d 273 ),
274 ),
7a7cc10b 275 'display_name' => array(
50fb255d 276 'name' => 'display_name',
277 'type' => 2,
278 'title' => 'Display Name',
5be22f39 279 'description' => 'Formatted name representing preferred format for display/print/other output.',
50fb255d 280 'maxlength' => 128,
281 'size' => 30,
282 'export' => TRUE,
283 'where' => 'civicrm_contact.display_name',
1d8ee3d6 284 'table_name' => 'civicrm_contact',
285 'entity' => 'Contact',
286 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 287 'html' => array(
288 'type' => 'Text',
5be22f39 289 'maxlength' => 128,
290 'size' => 30,
50fb255d 291 ),
292 ),
7a7cc10b 293 'nick_name' => array(
50fb255d 294 'name' => 'nick_name',
295 'type' => 2,
296 'title' => 'Nickname',
5be22f39 297 'description' => 'Nickname.',
50fb255d 298 'maxlength' => 128,
299 'size' => 30,
300 'import' => TRUE,
301 'where' => 'civicrm_contact.nick_name',
302 'headerPattern' => '/n(ick\\s)name|nick$/i',
303 'dataPattern' => '/^\\w+$/',
304 'export' => TRUE,
1d8ee3d6 305 'table_name' => 'civicrm_contact',
306 'entity' => 'Contact',
307 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 308 'html' => array(
309 'type' => 'Text',
5be22f39 310 'maxlength' => 128,
311 'size' => 30,
50fb255d 312 ),
313 ),
7a7cc10b 314 'legal_name' => array(
50fb255d 315 'name' => 'legal_name',
316 'type' => 2,
317 'title' => 'Legal Name',
5be22f39 318 'description' => 'Legal Name.',
50fb255d 319 'maxlength' => 128,
320 'size' => 30,
321 'import' => TRUE,
322 'where' => 'civicrm_contact.legal_name',
323 'headerPattern' => '/^legal|(l(egal\\s)?name)$/i',
324 'export' => TRUE,
1d8ee3d6 325 'table_name' => 'civicrm_contact',
326 'entity' => 'Contact',
327 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 328 'html' => array(
329 'type' => 'Text',
5be22f39 330 'maxlength' => 128,
331 'size' => 30,
50fb255d 332 ),
333 ),
7a7cc10b 334 'image_URL' => array(
50fb255d 335 'name' => 'image_URL',
5be22f39 336 'type' => 32,
50fb255d 337 'title' => 'Image Url',
5be22f39 338 'description' => 'optional URL for preferred image (photo, logo, etc.) to display for this contact.',
50fb255d 339 'import' => TRUE,
340 'where' => 'civicrm_contact.image_URL',
341 'export' => TRUE,
1d8ee3d6 342 'table_name' => 'civicrm_contact',
343 'entity' => 'Contact',
344 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 345 'html' => array(
5be22f39 346 'type' => 'File',
347 'rows' => 2,
348 'cols' => 80,
50fb255d 349 ),
350 ),
7a7cc10b 351 'preferred_communication_method' => array(
50fb255d 352 'name' => 'preferred_communication_method',
353 'type' => 2,
354 'title' => 'Preferred Communication Method',
5be22f39 355 'description' => 'What is the preferred mode of communication.',
50fb255d 356 'maxlength' => 255,
357 'size' => 45,
358 'import' => TRUE,
359 'where' => 'civicrm_contact.preferred_communication_method',
360 'headerPattern' => '/^p(ref\\w*\\s)?c(omm\\w*)|( meth\\w*)$/i',
361 'dataPattern' => '/^\\w+$/',
362 'export' => TRUE,
1d8ee3d6 363 'table_name' => 'civicrm_contact',
364 'entity' => 'Contact',
365 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 366 'html' => array(
367 'type' => 'Select',
5be22f39 368 'maxlength' => 255,
369 'size' => 45,
50fb255d 370 ),
371 'pseudoconstant' => array(
372 'optionGroupName' => 'preferred_communication_method',
5be22f39 373 'optionEditPath' => 'civicrm/admin/options/preferred_communication_method',
50fb255d 374 ),
375 ),
7a7cc10b 376 'preferred_language' => array(
50fb255d 377 'name' => 'preferred_language',
378 'type' => 2,
379 'title' => 'Preferred Language',
5be22f39 380 'description' => 'Which language is preferred for communication. FK to languages in civicrm_option_value.',
50fb255d 381 'maxlength' => 5,
382 'size' => 6,
383 'import' => TRUE,
384 'where' => 'civicrm_contact.preferred_language',
385 'headerPattern' => '/^lang/i',
386 'export' => TRUE,
1d8ee3d6 387 'table_name' => 'civicrm_contact',
388 'entity' => 'Contact',
389 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 390 'html' => array(
391 'type' => 'Select',
5be22f39 392 'maxlength' => 5,
393 'size' => 6,
50fb255d 394 ),
395 'pseudoconstant' => array(
396 'optionGroupName' => 'languages',
397 'keyColumn' => 'name',
5be22f39 398 'optionEditPath' => 'civicrm/admin/options/languages',
50fb255d 399 ),
400 ),
7a7cc10b 401 'preferred_mail_format' => array(
50fb255d 402 'name' => 'preferred_mail_format',
403 'type' => 2,
404 'title' => 'Preferred Mail Format',
5be22f39 405 'description' => 'What is the preferred mode of sending an email.',
50fb255d 406 'maxlength' => 8,
407 'size' => 8,
408 'import' => TRUE,
409 'where' => 'civicrm_contact.preferred_mail_format',
410 'headerPattern' => '/^p(ref\\w*\\s)?m(ail\\s)?f(orm\\w*)$/i',
411 'export' => TRUE,
412 'default' => 'Both',
1d8ee3d6 413 'table_name' => 'civicrm_contact',
414 'entity' => 'Contact',
415 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 416 'html' => array(
417 'type' => 'Select',
5be22f39 418 'maxlength' => 8,
419 'size' => 8,
50fb255d 420 ),
421 'pseudoconstant' => array(
422 'callback' => 'CRM_Core_SelectValues::pmf',
423 ),
424 ),
7a7cc10b 425 'hash' => array(
50fb255d 426 'name' => 'hash',
427 'type' => 2,
428 'title' => 'Contact Hash',
5be22f39 429 'description' => 'Key for validating requests related to this contact.',
50fb255d 430 'maxlength' => 32,
431 'size' => 20,
432 'export' => TRUE,
433 'where' => 'civicrm_contact.hash',
1d8ee3d6 434 'table_name' => 'civicrm_contact',
435 'entity' => 'Contact',
436 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 437 ),
7a7cc10b 438 'api_key' => array(
50fb255d 439 'name' => 'api_key',
440 'type' => 2,
441 'title' => 'Api Key',
5be22f39 442 'description' => 'API Key for validating requests related to this contact.',
50fb255d 443 'maxlength' => 32,
444 'size' => 20,
1d8ee3d6 445 'table_name' => 'civicrm_contact',
446 'entity' => 'Contact',
447 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 448 ),
7a7cc10b 449 'first_name' => array(
50fb255d 450 'name' => 'first_name',
451 'type' => 2,
452 'title' => 'First Name',
5be22f39 453 'description' => 'First Name.',
50fb255d 454 'maxlength' => 64,
455 'size' => 30,
456 'import' => TRUE,
457 'where' => 'civicrm_contact.first_name',
458 'headerPattern' => '/^first|(f(irst\\s)?name)$/i',
459 'dataPattern' => '/^\\w+$/',
460 'export' => TRUE,
1d8ee3d6 461 'table_name' => 'civicrm_contact',
462 'entity' => 'Contact',
463 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 464 'html' => array(
465 'type' => 'Text',
5be22f39 466 'maxlength' => 64,
467 'size' => 30,
50fb255d 468 ),
469 ),
7a7cc10b 470 'middle_name' => array(
50fb255d 471 'name' => 'middle_name',
472 'type' => 2,
473 'title' => 'Middle Name',
5be22f39 474 'description' => 'Middle Name.',
50fb255d 475 'maxlength' => 64,
5be22f39 476 'size' => 30,
50fb255d 477 'import' => TRUE,
478 'where' => 'civicrm_contact.middle_name',
479 'headerPattern' => '/^middle|(m(iddle\\s)?name)$/i',
480 'dataPattern' => '/^\\w+$/',
481 'export' => TRUE,
1d8ee3d6 482 'table_name' => 'civicrm_contact',
483 'entity' => 'Contact',
484 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 485 'html' => array(
486 'type' => 'Text',
5be22f39 487 'maxlength' => 64,
488 'size' => 30,
50fb255d 489 ),
490 ),
7a7cc10b 491 'last_name' => array(
50fb255d 492 'name' => 'last_name',
493 'type' => 2,
494 'title' => 'Last Name',
5be22f39 495 'description' => 'Last Name.',
50fb255d 496 'maxlength' => 64,
497 'size' => 30,
498 'import' => TRUE,
499 'where' => 'civicrm_contact.last_name',
500 'headerPattern' => '/^last|(l(ast\\s)?name)$/i',
501 'dataPattern' => '/^\\w+(\\s\\w+)?+$/',
502 'export' => TRUE,
1d8ee3d6 503 'table_name' => 'civicrm_contact',
504 'entity' => 'Contact',
505 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 506 'html' => array(
507 'type' => 'Text',
5be22f39 508 'maxlength' => 64,
509 'size' => 30,
50fb255d 510 ),
511 ),
9f1b81e0 512 'prefix_id' => array(
50fb255d 513 'name' => 'prefix_id',
514 'type' => 1,
515 'title' => 'Individual Prefix',
5be22f39 516 'description' => 'Prefix or Title for name (Ms, Mr...). FK to prefix ID',
50fb255d 517 'import' => TRUE,
518 'where' => 'civicrm_contact.prefix_id',
519 'headerPattern' => '/^(prefix|title)/i',
520 'dataPattern' => '/^(mr|ms|mrs|sir|dr)\\.?$/i',
521 'export' => TRUE,
1d8ee3d6 522 'table_name' => 'civicrm_contact',
523 'entity' => 'Contact',
524 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 525 'html' => array(
526 'type' => 'Select',
5be22f39 527 'size' => 6,
528 'maxlength' => 14,
50fb255d 529 ),
530 'pseudoconstant' => array(
531 'optionGroupName' => 'individual_prefix',
5be22f39 532 'optionEditPath' => 'civicrm/admin/options/individual_prefix',
50fb255d 533 ),
534 'api.aliases' => array(
535 '0' => 'individual_prefix',
536 '1' => 'individual_prefix_id',
537 ),
538 ),
9f1b81e0 539 'suffix_id' => array(
50fb255d 540 'name' => 'suffix_id',
541 'type' => 1,
542 'title' => 'Individual Suffix',
5be22f39 543 'description' => 'Suffix for name (Jr, Sr...). FK to suffix ID',
50fb255d 544 'import' => TRUE,
545 'where' => 'civicrm_contact.suffix_id',
546 'headerPattern' => '/^suffix$/i',
547 'dataPattern' => '/^(sr|jr)\\.?|i{2,}$/',
548 'export' => TRUE,
1d8ee3d6 549 'table_name' => 'civicrm_contact',
550 'entity' => 'Contact',
551 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 552 'html' => array(
553 'type' => 'Select',
5be22f39 554 'size' => 6,
555 'maxlength' => 14,
50fb255d 556 ),
557 'pseudoconstant' => array(
558 'optionGroupName' => 'individual_suffix',
5be22f39 559 'optionEditPath' => 'civicrm/admin/options/individual_suffix',
50fb255d 560 ),
561 'api.aliases' => array(
562 '0' => 'individual_suffix',
563 '1' => 'individual_suffix_id',
564 ),
565 ),
89bf81b4 566 'formal_title' => array(
50fb255d 567 'name' => 'formal_title',
568 'type' => 2,
569 'title' => 'Formal Title',
5be22f39 570 'description' => 'Formal (academic or similar) title in front of name. (Prof., Dr. etc.)',
50fb255d 571 'maxlength' => 64,
572 'size' => 30,
573 'import' => TRUE,
574 'where' => 'civicrm_contact.formal_title',
575 'headerPattern' => '/^title/i',
576 'export' => TRUE,
1d8ee3d6 577 'table_name' => 'civicrm_contact',
578 'entity' => 'Contact',
579 'bao' => 'CRM_Contact_BAO_Contact',
5be22f39 580 'html' => array(
581 'type' => 'Text',
582 'maxlength' => 64,
583 'size' => 30,
584 ),
50fb255d 585 ),
89bf81b4 586 'communication_style_id' => array(
50fb255d 587 'name' => 'communication_style_id',
588 'type' => 1,
589 'title' => 'Communication Style',
5be22f39 590 'description' => 'Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.',
50fb255d 591 'export' => TRUE,
592 'where' => 'civicrm_contact.communication_style_id',
1d8ee3d6 593 'table_name' => 'civicrm_contact',
594 'entity' => 'Contact',
595 'bao' => 'CRM_Contact_BAO_Contact',
5be22f39 596 'html' => array(
597 'type' => 'Select',
598 'size' => 6,
599 'maxlength' => 14,
600 ),
50fb255d 601 'pseudoconstant' => array(
602 'optionGroupName' => 'communication_style',
5be22f39 603 'optionEditPath' => 'civicrm/admin/options/communication_style',
50fb255d 604 ),
605 ),
7a7cc10b 606 'email_greeting_id' => array(
50fb255d 607 'name' => 'email_greeting_id',
608 'type' => 1,
609 'title' => 'Email Greeting ID',
5be22f39 610 'description' => 'FK to civicrm_option_value.id, that has to be valid registered Email Greeting.',
1d8ee3d6 611 'table_name' => 'civicrm_contact',
612 'entity' => 'Contact',
613 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 614 ),
7a7cc10b 615 'email_greeting_custom' => array(
50fb255d 616 'name' => 'email_greeting_custom',
617 'type' => 2,
618 'title' => 'Email Greeting Custom',
5be22f39 619 'description' => 'Custom Email Greeting.',
50fb255d 620 'maxlength' => 128,
621 'size' => 45,
622 'import' => TRUE,
623 'where' => 'civicrm_contact.email_greeting_custom',
1d8ee3d6 624 'table_name' => 'civicrm_contact',
625 'entity' => 'Contact',
626 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 627 'html' => array(
628 'type' => 'Text',
5be22f39 629 'maxlength' => 128,
630 'size' => 45,
50fb255d 631 ),
632 ),
7a7cc10b 633 'email_greeting_display' => array(
50fb255d 634 'name' => 'email_greeting_display',
635 'type' => 2,
636 'title' => 'Email Greeting',
5be22f39 637 'description' => 'Cache Email Greeting.',
50fb255d 638 'maxlength' => 255,
639 'size' => 45,
1d8ee3d6 640 'table_name' => 'civicrm_contact',
641 'entity' => 'Contact',
642 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 643 'html' => array(
644 'type' => 'Text',
5be22f39 645 'maxlength' => 255,
646 'size' => 45,
50fb255d 647 ),
648 ),
7a7cc10b 649 'postal_greeting_id' => array(
50fb255d 650 'name' => 'postal_greeting_id',
651 'type' => 1,
652 'title' => 'Postal Greeting ID',
5be22f39 653 'description' => 'FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.',
1d8ee3d6 654 'table_name' => 'civicrm_contact',
655 'entity' => 'Contact',
656 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 657 'html' => array(
658 'type' => 'Text',
5be22f39 659 'size' => 6,
660 'maxlength' => 14,
6a488035 661 ),
50fb255d 662 ),
7a7cc10b 663 'postal_greeting_custom' => array(
50fb255d 664 'name' => 'postal_greeting_custom',
665 'type' => 2,
666 'title' => 'Postal Greeting Custom',
5be22f39 667 'description' => 'Custom Postal greeting.',
50fb255d 668 'maxlength' => 128,
669 'size' => 45,
670 'import' => TRUE,
671 'where' => 'civicrm_contact.postal_greeting_custom',
1d8ee3d6 672 'table_name' => 'civicrm_contact',
673 'entity' => 'Contact',
674 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 675 'html' => array(
676 'type' => 'Text',
5be22f39 677 'maxlength' => 128,
678 'size' => 45,
50fb255d 679 ),
680 ),
7a7cc10b 681 'postal_greeting_display' => array(
50fb255d 682 'name' => 'postal_greeting_display',
683 'type' => 2,
684 'title' => 'Postal Greeting',
5be22f39 685 'description' => 'Cache Postal greeting.',
50fb255d 686 'maxlength' => 255,
687 'size' => 45,
1d8ee3d6 688 'table_name' => 'civicrm_contact',
689 'entity' => 'Contact',
690 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 691 'html' => array(
692 'type' => 'Text',
5be22f39 693 'maxlength' => 255,
694 'size' => 45,
50fb255d 695 ),
696 ),
7a7cc10b 697 'addressee_id' => array(
50fb255d 698 'name' => 'addressee_id',
699 'type' => 1,
700 'title' => 'Addressee ID',
5be22f39 701 'description' => 'FK to civicrm_option_value.id, that has to be valid registered Addressee.',
1d8ee3d6 702 'table_name' => 'civicrm_contact',
703 'entity' => 'Contact',
704 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 705 ),
7a7cc10b 706 'addressee_custom' => array(
50fb255d 707 'name' => 'addressee_custom',
708 'type' => 2,
709 'title' => 'Addressee Custom',
5be22f39 710 'description' => 'Custom Addressee.',
50fb255d 711 'maxlength' => 128,
712 'size' => 45,
713 'import' => TRUE,
714 'where' => 'civicrm_contact.addressee_custom',
1d8ee3d6 715 'table_name' => 'civicrm_contact',
716 'entity' => 'Contact',
717 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 718 'html' => array(
719 'type' => 'Text',
5be22f39 720 'maxlength' => 128,
721 'size' => 45,
50fb255d 722 ),
723 ),
7a7cc10b 724 'addressee_display' => array(
50fb255d 725 'name' => 'addressee_display',
726 'type' => 2,
727 'title' => 'Addressee',
5be22f39 728 'description' => 'Cache Addressee.',
50fb255d 729 'maxlength' => 255,
730 'size' => 45,
1d8ee3d6 731 'table_name' => 'civicrm_contact',
732 'entity' => 'Contact',
733 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 734 'html' => array(
735 'type' => 'Text',
5be22f39 736 'maxlength' => 255,
737 'size' => 45,
50fb255d 738 ),
739 ),
7a7cc10b 740 'job_title' => array(
50fb255d 741 'name' => 'job_title',
742 'type' => 2,
743 'title' => 'Job Title',
5be22f39 744 'description' => 'Job Title',
50fb255d 745 'maxlength' => 255,
5be22f39 746 'size' => 30,
50fb255d 747 'import' => TRUE,
748 'where' => 'civicrm_contact.job_title',
749 'headerPattern' => '/^job|(j(ob\\s)?title)$/i',
750 'dataPattern' => '//',
751 'export' => TRUE,
1d8ee3d6 752 'table_name' => 'civicrm_contact',
753 'entity' => 'Contact',
754 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 755 'html' => array(
756 'type' => 'Text',
5be22f39 757 'maxlength' => 255,
758 'size' => 30,
50fb255d 759 ),
760 ),
7a7cc10b 761 'gender_id' => array(
50fb255d 762 'name' => 'gender_id',
763 'type' => 1,
764 'title' => 'Gender',
5be22f39 765 'description' => 'FK to gender ID',
50fb255d 766 'import' => TRUE,
767 'where' => 'civicrm_contact.gender_id',
768 'headerPattern' => '/^gender$/i',
769 'export' => TRUE,
1d8ee3d6 770 'table_name' => 'civicrm_contact',
771 'entity' => 'Contact',
772 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 773 'html' => array(
774 'type' => 'Select',
5be22f39 775 'size' => 6,
776 'maxlength' => 14,
50fb255d 777 ),
778 'pseudoconstant' => array(
779 'optionGroupName' => 'gender',
5be22f39 780 'optionEditPath' => 'civicrm/admin/options/gender',
781 ),
782 'api.aliases' => array(
783 '0' => 'gender',
50fb255d 784 ),
785 ),
7a7cc10b 786 'birth_date' => array(
50fb255d 787 'name' => 'birth_date',
788 'type' => 4,
789 'title' => 'Birth Date',
5be22f39 790 'description' => 'Date of birth',
50fb255d 791 'import' => TRUE,
792 'where' => 'civicrm_contact.birth_date',
793 'headerPattern' => '/^birth|(b(irth\\s)?date)|D(\\W*)O(\\W*)B(\\W*)$/i',
794 'dataPattern' => '/\\d{4}-?\\d{2}-?\\d{2}/',
795 'export' => TRUE,
1d8ee3d6 796 'table_name' => 'civicrm_contact',
797 'entity' => 'Contact',
798 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 799 'html' => array(
800 'type' => 'Select Date',
1d8ee3d6 801 'format' => 'birth',
50fb255d 802 ),
803 ),
7a7cc10b 804 'is_deceased' => array(
50fb255d 805 'name' => 'is_deceased',
806 'type' => 16,
945ddec3 807 'title' => 'Deceased',
50fb255d 808 'import' => TRUE,
809 'where' => 'civicrm_contact.is_deceased',
810 'headerPattern' => '/i(s\\s)?d(eceased)$/i',
811 'export' => TRUE,
1d8ee3d6 812 'table_name' => 'civicrm_contact',
813 'entity' => 'Contact',
814 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 815 'html' => array(
816 'type' => 'CheckBox',
817 ),
818 ),
7a7cc10b 819 'deceased_date' => array(
50fb255d 820 'name' => 'deceased_date',
821 'type' => 4,
822 'title' => 'Deceased Date',
5be22f39 823 'description' => 'Date of deceased',
50fb255d 824 'import' => TRUE,
825 'where' => 'civicrm_contact.deceased_date',
826 'headerPattern' => '/^deceased|(d(eceased\\s)?date)$/i',
827 'export' => TRUE,
1d8ee3d6 828 'table_name' => 'civicrm_contact',
829 'entity' => 'Contact',
830 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 831 'html' => array(
832 'type' => 'Select Date',
1d8ee3d6 833 'format' => 'birth',
50fb255d 834 ),
835 ),
7a7cc10b 836 'household_name' => array(
50fb255d 837 'name' => 'household_name',
838 'type' => 2,
839 'title' => 'Household Name',
5be22f39 840 'description' => 'Household Name.',
50fb255d 841 'maxlength' => 128,
842 'size' => 30,
843 'import' => TRUE,
844 'where' => 'civicrm_contact.household_name',
845 'headerPattern' => '/^household|(h(ousehold\\s)?name)$/i',
846 'dataPattern' => '/^\\w+$/',
847 'export' => TRUE,
1d8ee3d6 848 'table_name' => 'civicrm_contact',
849 'entity' => 'Contact',
850 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 851 'html' => array(
852 'type' => 'Text',
5be22f39 853 'maxlength' => 128,
854 'size' => 30,
50fb255d 855 ),
856 ),
7a7cc10b 857 'primary_contact_id' => array(
50fb255d 858 'name' => 'primary_contact_id',
859 'type' => 1,
860 'title' => 'Household Primary Contact ID',
5be22f39 861 'description' => 'Optional FK to Primary Contact for this household.',
1d8ee3d6 862 'table_name' => 'civicrm_contact',
863 'entity' => 'Contact',
864 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 865 'FKClassName' => 'CRM_Contact_DAO_Contact',
866 'html' => array(
867 'type' => 'Select',
5be22f39 868 'size' => 6,
869 'maxlength' => 14,
50fb255d 870 ),
871 'FKApiName' => 'Contact',
872 ),
7a7cc10b 873 'organization_name' => array(
50fb255d 874 'name' => 'organization_name',
875 'type' => 2,
876 'title' => 'Organization Name',
5be22f39 877 'description' => 'Organization Name.',
50fb255d 878 'maxlength' => 128,
879 'size' => 30,
880 'import' => TRUE,
881 'where' => 'civicrm_contact.organization_name',
882 'headerPattern' => '/^organization|(o(rganization\\s)?name)$/i',
883 'dataPattern' => '/^\\w+$/',
884 'export' => TRUE,
1d8ee3d6 885 'table_name' => 'civicrm_contact',
886 'entity' => 'Contact',
887 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 888 'html' => array(
889 'type' => 'Text',
5be22f39 890 'maxlength' => 128,
891 'size' => 30,
50fb255d 892 ),
893 ),
7a7cc10b 894 'sic_code' => array(
50fb255d 895 'name' => 'sic_code',
896 'type' => 2,
897 'title' => 'Sic Code',
5be22f39 898 'description' => 'Standard Industry Classification Code.',
50fb255d 899 'maxlength' => 8,
900 'size' => 8,
901 'import' => TRUE,
902 'where' => 'civicrm_contact.sic_code',
903 'headerPattern' => '/^sic|(s(ic\\s)?code)$/i',
904 'export' => TRUE,
1d8ee3d6 905 'table_name' => 'civicrm_contact',
906 'entity' => 'Contact',
907 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 908 'html' => array(
909 'type' => 'Text',
5be22f39 910 'maxlength' => 8,
911 'size' => 8,
50fb255d 912 ),
913 ),
7a7cc10b 914 'user_unique_id' => array(
50fb255d 915 'name' => 'user_unique_id',
916 'type' => 2,
917 'title' => 'Unique ID (OpenID)',
5be22f39 918 'description' => 'the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM',
50fb255d 919 'maxlength' => 255,
920 'size' => 45,
921 'import' => TRUE,
922 'where' => 'civicrm_contact.user_unique_id',
923 'headerPattern' => '/^Open\\s?ID|u(niq\\w*)?\\s?ID/i',
924 'dataPattern' => '/^[\\w\\/\\:\\.]+$/',
925 'export' => TRUE,
926 'rule' => 'url',
1d8ee3d6 927 'table_name' => 'civicrm_contact',
928 'entity' => 'Contact',
929 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 930 'html' => array(
931 'type' => 'Text',
5be22f39 932 'maxlength' => 255,
933 'size' => 45,
50fb255d 934 ),
935 ),
7a7cc10b 936 'created_date' => array(
50fb255d 937 'name' => 'created_date',
938 'type' => 256,
939 'title' => 'Created Date',
5be22f39 940 'description' => 'When was the contact was created.',
50fb255d 941 'required' => '',
942 'export' => TRUE,
943 'where' => 'civicrm_contact.created_date',
944 'default' => 'NULL',
1d8ee3d6 945 'table_name' => 'civicrm_contact',
946 'entity' => 'Contact',
947 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 948 ),
7a7cc10b 949 'modified_date' => array(
50fb255d 950 'name' => 'modified_date',
951 'type' => 256,
952 'title' => 'Modified Date',
5be22f39 953 'description' => 'When was the contact (or closely related entity) was created or modified or deleted.',
50fb255d 954 'required' => '',
955 'export' => TRUE,
956 'where' => 'civicrm_contact.modified_date',
957 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
1d8ee3d6 958 'table_name' => 'civicrm_contact',
959 'entity' => 'Contact',
960 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 961 ),
7a7cc10b 962 'source' => array(
50fb255d 963 'name' => 'source',
964 'type' => 2,
d79be26c 965 'title' => 'Contact Source',
5be22f39 966 'description' => 'where contact come from, e.g. import, donate module insert...',
50fb255d 967 'maxlength' => 255,
968 'size' => 30,
969 'import' => TRUE,
970 'where' => 'civicrm_contact.source',
5be22f39 971 'headerPattern' => '/(C(ontact\\s)?Source)$/i',
50fb255d 972 'export' => TRUE,
1d8ee3d6 973 'table_name' => 'civicrm_contact',
974 'entity' => 'Contact',
975 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 976 'html' => array(
977 'type' => 'Text',
5be22f39 978 'maxlength' => 255,
979 'size' => 30,
50fb255d 980 ),
981 'uniqueName' => 'contact_source',
982 ),
7a7cc10b 983 'employer_id' => array(
50fb255d 984 'name' => 'employer_id',
985 'type' => 1,
5be22f39 986 'title' => 'Current Employer',
987 'description' => 'OPTIONAL FK to civicrm_contact record.',
50fb255d 988 'export' => TRUE,
989 'where' => 'civicrm_contact.employer_id',
1d8ee3d6 990 'table_name' => 'civicrm_contact',
991 'entity' => 'Contact',
992 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 993 'FKClassName' => 'CRM_Contact_DAO_Contact',
994 'html' => array(
5be22f39 995 'type' => 'EntityRef',
996 'size' => 6,
997 'maxlength' => 14,
50fb255d 998 ),
999 'uniqueName' => 'current_employer_id',
1000 'FKApiName' => 'Contact',
1001 ),
7a7cc10b 1002 'is_deleted' => array(
50fb255d 1003 'name' => 'is_deleted',
1004 'type' => 16,
1005 'title' => 'Contact is in Trash',
1006 'required' => TRUE,
1007 'export' => TRUE,
1008 'where' => 'civicrm_contact.is_deleted',
1d8ee3d6 1009 'table_name' => 'civicrm_contact',
1010 'entity' => 'Contact',
1011 'bao' => 'CRM_Contact_BAO_Contact',
50fb255d 1012 'html' => array(
1013 'type' => 'CheckBox',
1014 ),
1015 'uniqueName' => 'contact_is_deleted',
1016 ),
7a7cc10b 1017 'custom_1' => array(
50fb255d 1018 'label' => 'Our special field',
1019 'groupTitle' => 'select_test_g',
1020 'data_type' => 'String',
1021 'html_type' => 'Select',
1022 'default_value' => '',
1023 'text_length' => '',
1024 'options_per_line' => '',
1025 'custom_group_id' => '1',
1026 'extends' => 'Contact',
1027 'is_search_range' => 0,
1028 'extends_entity_column_value' => '',
1029 'extends_entity_column_id' => '',
1030 'is_view' => 0,
1031 'is_multiple' => 0,
5be22f39 1032 'option_group_id' => '105',
50fb255d 1033 'date_format' => '',
1034 'time_format' => '',
1035 'is_required' => '1',
5be22f39 1036 'table_name' => 'civicrm_value_select_test_g_1',
1037 'column_name' => 'our_special_field_1',
1038 'pseudoconstant' => array(
1d8ee3d6 1039 'optionGroupName' => 'our_special_field_20170207021937',
1040 'optionEditPath' => 'civicrm/admin/options/our_special_field_20170207021937',
5be22f39 1041 ),
50fb255d 1042 'name' => 'custom_1',
1043 'title' => 'Our special field',
1044 'type' => 2,
1045 'options' => array(
1046 '1' => 'Label1',
1047 '2' => 'Label2',
1048 ),
1049 ),
7a7cc10b 1050 'current_employer' => array(
50fb255d 1051 'title' => 'Current Employer',
1052 'description' => 'Name of Current Employer',
1053 'type' => 2,
5c49fee0 1054 'name' => 'current_employer',
50fb255d 1055 ),
7a7cc10b 1056 'dupe_check' => array(
50fb255d 1057 'title' => 'Check for Duplicates',
1058 'description' => 'Throw error if contact create matches dedupe rule',
5be22f39 1059 'type' => 16,
5c49fee0 1060 'name' => 'dupe_check',
50fb255d 1061 ),
6a488035 1062 ),
50fb255d 1063 );
6a488035 1064
fb32de45 1065 return $expectedResult;
6a488035
TO
1066}
1067
a828d7b8 1068/*
50fb255d 1069* This example has been generated from the API test suite.
a828d7b8
CW
1070* The test that created it is called "testCustomFieldCreateWithOptionValues"
1071* and can be found at:
69d79249 1072* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
6a488035
TO
1073*
1074* You can see the outcome of the API tests at
69d79249 1075* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
1076*
1077* To Learn about the API read
69d79249 1078* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 1079*
69d79249 1080* Browse the api on your own site with the api explorer
41d4d31f 1081* http://MYSITE.ORG/path/to/civicrm/api
6a488035
TO
1082*
1083* Read more about testing here
1084* http://wiki.civicrm.org/confluence/display/CRM/Testing
1085*
1086* API Standards documentation:
1087* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 1088*/