5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Core/CustomField.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:492b1be45dc41c15b35371410a074393)
13 * Database access object for the CustomField entity.
15 class CRM_Core_DAO_CustomField
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_custom_field';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
32 * Unique Custom Field ID
39 * FK to civicrm_custom_group.
43 public $custom_group_id;
46 * Variable name/programmatic handle for this group.
53 * Text for form field label (also friendly name for administering this custom property).
60 * Controls location of data storage in extended_data table.
67 * HTML types plus several built-in extended types.
74 * Use form_options.is_default for field_types which use options.
78 public $default_value;
81 * Is a value required for this property.
88 * Is this property searchable.
92 public $is_searchable;
95 * Is this property range searchable.
99 public $is_search_range;
102 * Controls field display order within an extended property group.
109 * Description and/or help text to display before this field.
116 * Description and/or help text to display after this field.
123 * Optional format instructions for specific field types, like date types.
130 * Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes
137 * Optional scripting attributes for field.
144 * Is this property active?
151 * Is this property set by PHP Code? A code field is viewable but not editable
158 * number of options per line for checkbox and radio
162 public $options_per_line;
165 * field length if alphanumeric
172 * Date may be up to start_date_years years prior to the current date.
176 public $start_date_years;
179 * Date may be up to end_date_years years after the current date.
183 public $end_date_years;
186 * date format for custom date
193 * time format for custom date
200 * Number of columns in Note Field
204 public $note_columns;
207 * Number of rows in Note Field
214 * Name of the column that holds the values for this field.
221 * For elements with options, the option group id that is used
225 public $option_group_id;
228 * Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.
235 * Should the multi-record custom field values be displayed in tab table listing
244 public function __construct() {
245 $this->__table
= 'civicrm_custom_field';
246 parent
::__construct();
250 * Returns foreign keys and entity references.
253 * [CRM_Core_Reference_Interface]
255 public static function getReferenceColumns() {
256 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
257 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
258 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'custom_group_id', 'civicrm_custom_group', 'id');
259 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'option_group_id', 'civicrm_option_group', 'id');
260 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
262 return Civi
::$statics[__CLASS__
]['links'];
266 * Returns all the column names of this table
270 public static function &fields() {
271 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
272 Civi
::$statics[__CLASS__
]['fields'] = [
275 'type' => CRM_Utils_Type
::T_INT
,
276 'title' => ts('Custom Field ID'),
277 'description' => ts('Unique Custom Field ID'),
279 'where' => 'civicrm_custom_field.id',
280 'table_name' => 'civicrm_custom_field',
281 'entity' => 'CustomField',
282 'bao' => 'CRM_Core_BAO_CustomField',
285 'custom_group_id' => [
286 'name' => 'custom_group_id',
287 'type' => CRM_Utils_Type
::T_INT
,
288 'title' => ts('Custom Group'),
289 'description' => ts('FK to civicrm_custom_group.'),
291 'where' => 'civicrm_custom_field.custom_group_id',
292 'table_name' => 'civicrm_custom_field',
293 'entity' => 'CustomField',
294 'bao' => 'CRM_Core_BAO_CustomField',
296 'FKClassName' => 'CRM_Core_DAO_CustomGroup',
300 'pseudoconstant' => [
301 'table' => 'civicrm_custom_group',
303 'labelColumn' => 'title',
308 'type' => CRM_Utils_Type
::T_STRING
,
309 'title' => ts('Custom Field Name'),
310 'description' => ts('Variable name/programmatic handle for this group.'),
312 'size' => CRM_Utils_Type
::BIG
,
313 'where' => 'civicrm_custom_field.name',
314 'table_name' => 'civicrm_custom_field',
315 'entity' => 'CustomField',
316 'bao' => 'CRM_Core_BAO_CustomField',
321 'type' => CRM_Utils_Type
::T_STRING
,
322 'title' => ts('Custom Field Label'),
323 'description' => ts('Text for form field label (also friendly name for administering this custom property).'),
326 'size' => CRM_Utils_Type
::HUGE
,
327 'where' => 'civicrm_custom_field.label',
328 'table_name' => 'civicrm_custom_field',
329 'entity' => 'CustomField',
330 'bao' => 'CRM_Core_BAO_CustomField',
334 'name' => 'data_type',
335 'type' => CRM_Utils_Type
::T_STRING
,
336 'title' => ts('Custom Field Data Type'),
337 'description' => ts('Controls location of data storage in extended_data table.'),
340 'size' => CRM_Utils_Type
::TWELVE
,
341 'where' => 'civicrm_custom_field.data_type',
342 'table_name' => 'civicrm_custom_field',
343 'entity' => 'CustomField',
344 'bao' => 'CRM_Core_BAO_CustomField',
349 'pseudoconstant' => [
350 'callback' => 'CRM_Core_BAO_CustomField::dataType',
354 'name' => 'html_type',
355 'type' => CRM_Utils_Type
::T_STRING
,
356 'title' => ts('Custom Field HTML Type'),
357 'description' => ts('HTML types plus several built-in extended types.'),
360 'size' => CRM_Utils_Type
::MEDIUM
,
361 'where' => 'civicrm_custom_field.html_type',
362 'table_name' => 'civicrm_custom_field',
363 'entity' => 'CustomField',
364 'bao' => 'CRM_Core_BAO_CustomField',
366 'pseudoconstant' => [
367 'callback' => 'CRM_Core_SelectValues::customHtmlType',
371 'name' => 'default_value',
372 'type' => CRM_Utils_Type
::T_STRING
,
373 'title' => ts('Custom Field Default'),
374 'description' => ts('Use form_options.is_default for field_types which use options.'),
376 'size' => CRM_Utils_Type
::HUGE
,
377 'where' => 'civicrm_custom_field.default_value',
378 'table_name' => 'civicrm_custom_field',
379 'entity' => 'CustomField',
380 'bao' => 'CRM_Core_BAO_CustomField',
384 'name' => 'is_required',
385 'type' => CRM_Utils_Type
::T_BOOLEAN
,
386 'title' => ts('Custom Field Is Required?'),
387 'description' => ts('Is a value required for this property.'),
388 'where' => 'civicrm_custom_field.is_required',
390 'table_name' => 'civicrm_custom_field',
391 'entity' => 'CustomField',
392 'bao' => 'CRM_Core_BAO_CustomField',
396 'name' => 'is_searchable',
397 'type' => CRM_Utils_Type
::T_BOOLEAN
,
398 'title' => ts('Allow Searching on Field?'),
399 'description' => ts('Is this property searchable.'),
400 'where' => 'civicrm_custom_field.is_searchable',
402 'table_name' => 'civicrm_custom_field',
403 'entity' => 'CustomField',
404 'bao' => 'CRM_Core_BAO_CustomField',
407 'is_search_range' => [
408 'name' => 'is_search_range',
409 'type' => CRM_Utils_Type
::T_BOOLEAN
,
410 'title' => ts('Search as a Range'),
411 'description' => ts('Is this property range searchable.'),
412 'where' => 'civicrm_custom_field.is_search_range',
414 'table_name' => 'civicrm_custom_field',
415 'entity' => 'CustomField',
416 'bao' => 'CRM_Core_BAO_CustomField',
421 'type' => CRM_Utils_Type
::T_INT
,
422 'title' => ts('Order'),
423 'description' => ts('Controls field display order within an extended property group.'),
425 'where' => 'civicrm_custom_field.weight',
427 'table_name' => 'civicrm_custom_field',
428 'entity' => 'CustomField',
429 'bao' => 'CRM_Core_BAO_CustomField',
433 'name' => 'help_pre',
434 'type' => CRM_Utils_Type
::T_TEXT
,
435 'title' => ts('Custom Field Pre Text'),
436 'description' => ts('Description and/or help text to display before this field.'),
437 'where' => 'civicrm_custom_field.help_pre',
438 'table_name' => 'civicrm_custom_field',
439 'entity' => 'CustomField',
440 'bao' => 'CRM_Core_BAO_CustomField',
444 'name' => 'help_post',
445 'type' => CRM_Utils_Type
::T_TEXT
,
446 'title' => ts('Custom Field Post Text'),
447 'description' => ts('Description and/or help text to display after this field.'),
448 'where' => 'civicrm_custom_field.help_post',
449 'table_name' => 'civicrm_custom_field',
450 'entity' => 'CustomField',
451 'bao' => 'CRM_Core_BAO_CustomField',
456 'type' => CRM_Utils_Type
::T_STRING
,
457 'title' => ts('Custom Field Formatting'),
458 'description' => ts('Optional format instructions for specific field types, like date types.'),
460 'size' => CRM_Utils_Type
::BIG
,
461 'where' => 'civicrm_custom_field.mask',
462 'table_name' => 'civicrm_custom_field',
463 'entity' => 'CustomField',
464 'bao' => 'CRM_Core_BAO_CustomField',
468 'name' => 'attributes',
469 'type' => CRM_Utils_Type
::T_STRING
,
470 'title' => ts('Custom Field Attributes'),
471 'description' => ts('Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes'),
473 'size' => CRM_Utils_Type
::HUGE
,
474 'where' => 'civicrm_custom_field.attributes',
475 'table_name' => 'civicrm_custom_field',
476 'entity' => 'CustomField',
477 'bao' => 'CRM_Core_BAO_CustomField',
481 'name' => 'javascript',
482 'type' => CRM_Utils_Type
::T_STRING
,
483 'title' => ts('Custom Field Javascript'),
484 'description' => ts('Optional scripting attributes for field.'),
486 'size' => CRM_Utils_Type
::HUGE
,
487 'where' => 'civicrm_custom_field.javascript',
488 'table_name' => 'civicrm_custom_field',
489 'entity' => 'CustomField',
490 'bao' => 'CRM_Core_BAO_CustomField',
494 'name' => 'is_active',
495 'type' => CRM_Utils_Type
::T_BOOLEAN
,
496 'title' => ts('Custom Field Is Active?'),
497 'description' => ts('Is this property active?'),
498 'where' => 'civicrm_custom_field.is_active',
500 'table_name' => 'civicrm_custom_field',
501 'entity' => 'CustomField',
502 'bao' => 'CRM_Core_BAO_CustomField',
507 'type' => CRM_Utils_Type
::T_BOOLEAN
,
508 'title' => ts('Field is Viewable'),
509 'description' => ts('Is this property set by PHP Code? A code field is viewable but not editable'),
510 'where' => 'civicrm_custom_field.is_view',
512 'table_name' => 'civicrm_custom_field',
513 'entity' => 'CustomField',
514 'bao' => 'CRM_Core_BAO_CustomField',
517 'options_per_line' => [
518 'name' => 'options_per_line',
519 'type' => CRM_Utils_Type
::T_INT
,
520 'title' => ts('Field Options Per Line'),
521 'description' => ts('number of options per line for checkbox and radio'),
522 'where' => 'civicrm_custom_field.options_per_line',
523 'table_name' => 'civicrm_custom_field',
524 'entity' => 'CustomField',
525 'bao' => 'CRM_Core_BAO_CustomField',
529 'name' => 'text_length',
530 'type' => CRM_Utils_Type
::T_INT
,
531 'title' => ts('Field Length'),
532 'description' => ts('field length if alphanumeric'),
533 'where' => 'civicrm_custom_field.text_length',
534 'table_name' => 'civicrm_custom_field',
535 'entity' => 'CustomField',
536 'bao' => 'CRM_Core_BAO_CustomField',
539 'start_date_years' => [
540 'name' => 'start_date_years',
541 'type' => CRM_Utils_Type
::T_INT
,
542 'title' => ts('Field Start Date'),
543 'description' => ts('Date may be up to start_date_years years prior to the current date.'),
544 'where' => 'civicrm_custom_field.start_date_years',
545 'table_name' => 'civicrm_custom_field',
546 'entity' => 'CustomField',
547 'bao' => 'CRM_Core_BAO_CustomField',
550 'end_date_years' => [
551 'name' => 'end_date_years',
552 'type' => CRM_Utils_Type
::T_INT
,
553 'title' => ts('Field End Date'),
554 'description' => ts('Date may be up to end_date_years years after the current date.'),
555 'where' => 'civicrm_custom_field.end_date_years',
556 'table_name' => 'civicrm_custom_field',
557 'entity' => 'CustomField',
558 'bao' => 'CRM_Core_BAO_CustomField',
562 'name' => 'date_format',
563 'type' => CRM_Utils_Type
::T_STRING
,
564 'title' => ts('Field Data Format'),
565 'description' => ts('date format for custom date'),
567 'size' => CRM_Utils_Type
::BIG
,
568 'where' => 'civicrm_custom_field.date_format',
569 'table_name' => 'civicrm_custom_field',
570 'entity' => 'CustomField',
571 'bao' => 'CRM_Core_BAO_CustomField',
573 'pseudoconstant' => [
574 'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats',
578 'name' => 'time_format',
579 'type' => CRM_Utils_Type
::T_INT
,
580 'title' => ts('Field Time Format'),
581 'description' => ts('time format for custom date'),
582 'where' => 'civicrm_custom_field.time_format',
583 'table_name' => 'civicrm_custom_field',
584 'entity' => 'CustomField',
585 'bao' => 'CRM_Core_BAO_CustomField',
587 'pseudoconstant' => [
588 'callback' => 'CRM_Core_SelectValues::getTimeFormats',
592 'name' => 'note_columns',
593 'type' => CRM_Utils_Type
::T_INT
,
594 'title' => ts('Field Note Columns'),
595 'description' => ts('Number of columns in Note Field'),
596 'where' => 'civicrm_custom_field.note_columns',
597 'table_name' => 'civicrm_custom_field',
598 'entity' => 'CustomField',
599 'bao' => 'CRM_Core_BAO_CustomField',
603 'name' => 'note_rows',
604 'type' => CRM_Utils_Type
::T_INT
,
605 'title' => ts('Field Note Rows'),
606 'description' => ts('Number of rows in Note Field'),
607 'where' => 'civicrm_custom_field.note_rows',
608 'table_name' => 'civicrm_custom_field',
609 'entity' => 'CustomField',
610 'bao' => 'CRM_Core_BAO_CustomField',
614 'name' => 'column_name',
615 'type' => CRM_Utils_Type
::T_STRING
,
616 'title' => ts('Field Column Name'),
617 'description' => ts('Name of the column that holds the values for this field.'),
619 'size' => CRM_Utils_Type
::HUGE
,
620 'where' => 'civicrm_custom_field.column_name',
621 'table_name' => 'civicrm_custom_field',
622 'entity' => 'CustomField',
623 'bao' => 'CRM_Core_BAO_CustomField',
626 'option_group_id' => [
627 'name' => 'option_group_id',
628 'type' => CRM_Utils_Type
::T_INT
,
629 'title' => ts('Field Option Group'),
630 'description' => ts('For elements with options, the option group id that is used'),
631 'where' => 'civicrm_custom_field.option_group_id',
632 'table_name' => 'civicrm_custom_field',
633 'entity' => 'CustomField',
634 'bao' => 'CRM_Core_BAO_CustomField',
636 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
637 'pseudoconstant' => [
638 'table' => 'civicrm_option_group',
640 'labelColumn' => 'title',
645 'type' => CRM_Utils_Type
::T_STRING
,
646 'title' => ts('Field Filter'),
647 'description' => ts('Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.'),
649 'size' => CRM_Utils_Type
::HUGE
,
650 'where' => 'civicrm_custom_field.filter',
651 'table_name' => 'civicrm_custom_field',
652 'entity' => 'CustomField',
653 'bao' => 'CRM_Core_BAO_CustomField',
657 'name' => 'in_selector',
658 'type' => CRM_Utils_Type
::T_BOOLEAN
,
659 'title' => ts('Field Display'),
660 'description' => ts('Should the multi-record custom field values be displayed in tab table listing'),
661 'where' => 'civicrm_custom_field.in_selector',
663 'table_name' => 'civicrm_custom_field',
664 'entity' => 'CustomField',
665 'bao' => 'CRM_Core_BAO_CustomField',
669 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
671 return Civi
::$statics[__CLASS__
]['fields'];
675 * Return a mapping from field-name to the corresponding key (as used in fields()).
678 * Array(string $name => string $uniqueName).
680 public static function &fieldKeys() {
681 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
682 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
684 return Civi
::$statics[__CLASS__
]['fieldKeys'];
688 * Returns the names of this table
692 public static function getTableName() {
693 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
697 * Returns if this table needs to be logged
701 public function getLog() {
706 * Returns the list of fields that can be imported
708 * @param bool $prefix
712 public static function &import($prefix = FALSE) {
713 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'custom_field', $prefix, []);
718 * Returns the list of fields that can be exported
720 * @param bool $prefix
724 public static function &export($prefix = FALSE) {
725 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'custom_field', $prefix, []);
730 * Returns the list of indices
732 * @param bool $localize
736 public static function indices($localize = TRUE) {
738 'UI_label_custom_group_id' => [
739 'name' => 'UI_label_custom_group_id',
742 1 => 'custom_group_id',
744 'localizable' => TRUE,
746 'sig' => 'civicrm_custom_field::1::label::custom_group_id',
748 'UI_name_custom_group_id' => [
749 'name' => 'UI_name_custom_group_id',
752 1 => 'custom_group_id',
754 'localizable' => FALSE,
756 'sig' => 'civicrm_custom_field::1::name::custom_group_id',
759 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;