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