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:3e3cc05b51da1e0e51ac5dcbbedde392)
13 * Database access object for the CustomField entity.
15 class CRM_Core_DAO_CustomField
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_custom_field';
27 * Field to show when displaying a record.
31 public static $_labelField = 'label';
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = TRUE;
41 * Unique Custom Field ID
48 * FK to civicrm_custom_group.
52 public $custom_group_id;
55 * Variable name/programmatic handle for this group.
62 * Text for form field label (also friendly name for administering this custom property).
69 * Controls location of data storage in extended_data table.
76 * HTML types plus several built-in extended types.
83 * Use form_options.is_default for field_types which use options.
87 public $default_value;
90 * Is a value required for this property.
97 * Is this property searchable.
101 public $is_searchable;
104 * Is this property range searchable.
108 public $is_search_range;
111 * Controls field display order within an extended property group.
118 * Description and/or help text to display before this field.
125 * Description and/or help text to display after this field.
132 * Optional format instructions for specific field types, like date types.
139 * Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes
146 * Optional scripting attributes for field.
153 * Is this property active?
160 * Is this property set by PHP Code? A code field is viewable but not editable
167 * number of options per line for checkbox and radio
171 public $options_per_line;
174 * field length if alphanumeric
181 * Date may be up to start_date_years years prior to the current date.
185 public $start_date_years;
188 * Date may be up to end_date_years years after the current date.
192 public $end_date_years;
195 * date format for custom date
202 * time format for custom date
209 * Number of columns in Note Field
213 public $note_columns;
216 * Number of rows in Note Field
223 * Name of the column that holds the values for this field.
230 * For elements with options, the option group id that is used
234 public $option_group_id;
237 * Serialization method - a non-zero value indicates a multi-valued field.
244 * Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.
251 * Should the multi-record custom field values be displayed in tab table listing
260 public function __construct() {
261 $this->__table
= 'civicrm_custom_field';
262 parent
::__construct();
266 * Returns localized title of this entity.
268 * @param bool $plural
269 * Whether to return the plural version of the title.
271 public static function getEntityTitle($plural = FALSE) {
272 return $plural ?
ts('Custom Fields') : ts('Custom Field');
276 * Returns foreign keys and entity references.
279 * [CRM_Core_Reference_Interface]
281 public static function getReferenceColumns() {
282 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
283 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
284 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'custom_group_id', 'civicrm_custom_group', 'id');
285 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'option_group_id', 'civicrm_option_group', 'id');
286 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
288 return Civi
::$statics[__CLASS__
]['links'];
292 * Returns all the column names of this table
296 public static function &fields() {
297 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
298 Civi
::$statics[__CLASS__
]['fields'] = [
301 'type' => CRM_Utils_Type
::T_INT
,
302 'title' => ts('Custom Field ID'),
303 'description' => ts('Unique Custom Field ID'),
305 'where' => 'civicrm_custom_field.id',
306 'table_name' => 'civicrm_custom_field',
307 'entity' => 'CustomField',
308 'bao' => 'CRM_Core_BAO_CustomField',
312 'custom_group_id' => [
313 'name' => 'custom_group_id',
314 'type' => CRM_Utils_Type
::T_INT
,
315 'title' => ts('Custom Group'),
316 'description' => ts('FK to civicrm_custom_group.'),
318 'where' => 'civicrm_custom_field.custom_group_id',
319 'table_name' => 'civicrm_custom_field',
320 'entity' => 'CustomField',
321 'bao' => 'CRM_Core_BAO_CustomField',
323 'FKClassName' => 'CRM_Core_DAO_CustomGroup',
327 'pseudoconstant' => [
328 'table' => 'civicrm_custom_group',
330 'labelColumn' => 'title',
336 'type' => CRM_Utils_Type
::T_STRING
,
337 'title' => ts('Custom Field Name'),
338 'description' => ts('Variable name/programmatic handle for this group.'),
340 'size' => CRM_Utils_Type
::BIG
,
341 'where' => 'civicrm_custom_field.name',
342 'table_name' => 'civicrm_custom_field',
343 'entity' => 'CustomField',
344 'bao' => 'CRM_Core_BAO_CustomField',
350 'type' => CRM_Utils_Type
::T_STRING
,
351 'title' => ts('Custom Field Label'),
352 'description' => ts('Text for form field label (also friendly name for administering this custom property).'),
355 'size' => CRM_Utils_Type
::HUGE
,
356 'where' => 'civicrm_custom_field.label',
357 'table_name' => 'civicrm_custom_field',
358 'entity' => 'CustomField',
359 'bao' => 'CRM_Core_BAO_CustomField',
364 'name' => 'data_type',
365 'type' => CRM_Utils_Type
::T_STRING
,
366 'title' => ts('Custom Field Data Type'),
367 'description' => ts('Controls location of data storage in extended_data table.'),
370 'size' => CRM_Utils_Type
::TWELVE
,
371 'where' => 'civicrm_custom_field.data_type',
372 'table_name' => 'civicrm_custom_field',
373 'entity' => 'CustomField',
374 'bao' => 'CRM_Core_BAO_CustomField',
378 'label' => ts("Data Type"),
380 'pseudoconstant' => [
381 'callback' => 'CRM_Core_BAO_CustomField::dataType',
386 'name' => 'html_type',
387 'type' => CRM_Utils_Type
::T_STRING
,
388 'title' => ts('Custom Field HTML Type'),
389 'description' => ts('HTML types plus several built-in extended types.'),
392 'size' => CRM_Utils_Type
::MEDIUM
,
393 'where' => 'civicrm_custom_field.html_type',
394 'table_name' => 'civicrm_custom_field',
395 'entity' => 'CustomField',
396 'bao' => 'CRM_Core_BAO_CustomField',
400 'label' => ts("Field Input Type"),
402 'pseudoconstant' => [
403 'callback' => 'CRM_Core_SelectValues::customHtmlType',
408 'name' => 'default_value',
409 'type' => CRM_Utils_Type
::T_STRING
,
410 'title' => ts('Custom Field Default'),
411 'description' => ts('Use form_options.is_default for field_types which use options.'),
413 'size' => CRM_Utils_Type
::HUGE
,
414 'where' => 'civicrm_custom_field.default_value',
415 'table_name' => 'civicrm_custom_field',
416 'entity' => 'CustomField',
417 'bao' => 'CRM_Core_BAO_CustomField',
422 'name' => 'is_required',
423 'type' => CRM_Utils_Type
::T_BOOLEAN
,
424 'title' => ts('Custom Field Is Required?'),
425 'description' => ts('Is a value required for this property.'),
426 'where' => 'civicrm_custom_field.is_required',
428 'table_name' => 'civicrm_custom_field',
429 'entity' => 'CustomField',
430 'bao' => 'CRM_Core_BAO_CustomField',
435 'name' => 'is_searchable',
436 'type' => CRM_Utils_Type
::T_BOOLEAN
,
437 'title' => ts('Allow Searching on Field?'),
438 'description' => ts('Is this property searchable.'),
439 'where' => 'civicrm_custom_field.is_searchable',
441 'table_name' => 'civicrm_custom_field',
442 'entity' => 'CustomField',
443 'bao' => 'CRM_Core_BAO_CustomField',
447 'is_search_range' => [
448 'name' => 'is_search_range',
449 'type' => CRM_Utils_Type
::T_BOOLEAN
,
450 'title' => ts('Search as a Range'),
451 'description' => ts('Is this property range searchable.'),
452 'where' => 'civicrm_custom_field.is_search_range',
454 'table_name' => 'civicrm_custom_field',
455 'entity' => 'CustomField',
456 'bao' => 'CRM_Core_BAO_CustomField',
462 'type' => CRM_Utils_Type
::T_INT
,
463 'title' => ts('Order'),
464 'description' => ts('Controls field display order within an extended property group.'),
466 'where' => 'civicrm_custom_field.weight',
468 'table_name' => 'civicrm_custom_field',
469 'entity' => 'CustomField',
470 'bao' => 'CRM_Core_BAO_CustomField',
475 'name' => 'help_pre',
476 'type' => CRM_Utils_Type
::T_TEXT
,
477 'title' => ts('Custom Field Pre Text'),
478 'description' => ts('Description and/or help text to display before this field.'),
479 'where' => 'civicrm_custom_field.help_pre',
480 'table_name' => 'civicrm_custom_field',
481 'entity' => 'CustomField',
482 'bao' => 'CRM_Core_BAO_CustomField',
487 'name' => 'help_post',
488 'type' => CRM_Utils_Type
::T_TEXT
,
489 'title' => ts('Custom Field Post Text'),
490 'description' => ts('Description and/or help text to display after this field.'),
491 'where' => 'civicrm_custom_field.help_post',
492 'table_name' => 'civicrm_custom_field',
493 'entity' => 'CustomField',
494 'bao' => 'CRM_Core_BAO_CustomField',
500 'type' => CRM_Utils_Type
::T_STRING
,
501 'title' => ts('Custom Field Formatting'),
502 'description' => ts('Optional format instructions for specific field types, like date types.'),
504 'size' => CRM_Utils_Type
::BIG
,
505 'where' => 'civicrm_custom_field.mask',
506 'table_name' => 'civicrm_custom_field',
507 'entity' => 'CustomField',
508 'bao' => 'CRM_Core_BAO_CustomField',
513 'name' => 'attributes',
514 'type' => CRM_Utils_Type
::T_STRING
,
515 'title' => ts('Custom Field Attributes'),
516 'description' => ts('Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes'),
518 'size' => CRM_Utils_Type
::HUGE
,
519 'where' => 'civicrm_custom_field.attributes',
520 'table_name' => 'civicrm_custom_field',
521 'entity' => 'CustomField',
522 'bao' => 'CRM_Core_BAO_CustomField',
527 'name' => 'javascript',
528 'type' => CRM_Utils_Type
::T_STRING
,
529 'title' => ts('Custom Field Javascript'),
530 'description' => ts('Optional scripting attributes for field.'),
532 'size' => CRM_Utils_Type
::HUGE
,
533 'where' => 'civicrm_custom_field.javascript',
534 'table_name' => 'civicrm_custom_field',
535 'entity' => 'CustomField',
536 'bao' => 'CRM_Core_BAO_CustomField',
541 'name' => 'is_active',
542 'type' => CRM_Utils_Type
::T_BOOLEAN
,
543 'title' => ts('Custom Field Is Active?'),
544 'description' => ts('Is this property active?'),
545 'where' => 'civicrm_custom_field.is_active',
547 'table_name' => 'civicrm_custom_field',
548 'entity' => 'CustomField',
549 'bao' => 'CRM_Core_BAO_CustomField',
555 'type' => CRM_Utils_Type
::T_BOOLEAN
,
556 'title' => ts('Field is Viewable'),
557 'description' => ts('Is this property set by PHP Code? A code field is viewable but not editable'),
558 'where' => 'civicrm_custom_field.is_view',
560 'table_name' => 'civicrm_custom_field',
561 'entity' => 'CustomField',
562 'bao' => 'CRM_Core_BAO_CustomField',
566 'options_per_line' => [
567 'name' => 'options_per_line',
568 'type' => CRM_Utils_Type
::T_INT
,
569 'title' => ts('Field Options Per Line'),
570 'description' => ts('number of options per line for checkbox and radio'),
571 'where' => 'civicrm_custom_field.options_per_line',
572 'table_name' => 'civicrm_custom_field',
573 'entity' => 'CustomField',
574 'bao' => 'CRM_Core_BAO_CustomField',
579 'name' => 'text_length',
580 'type' => CRM_Utils_Type
::T_INT
,
581 'title' => ts('Field Length'),
582 'description' => ts('field length if alphanumeric'),
583 'where' => 'civicrm_custom_field.text_length',
584 'table_name' => 'civicrm_custom_field',
585 'entity' => 'CustomField',
586 'bao' => 'CRM_Core_BAO_CustomField',
590 'start_date_years' => [
591 'name' => 'start_date_years',
592 'type' => CRM_Utils_Type
::T_INT
,
593 'title' => ts('Field Start Date'),
594 'description' => ts('Date may be up to start_date_years years prior to the current date.'),
595 'where' => 'civicrm_custom_field.start_date_years',
596 'table_name' => 'civicrm_custom_field',
597 'entity' => 'CustomField',
598 'bao' => 'CRM_Core_BAO_CustomField',
602 'end_date_years' => [
603 'name' => 'end_date_years',
604 'type' => CRM_Utils_Type
::T_INT
,
605 'title' => ts('Field End Date'),
606 'description' => ts('Date may be up to end_date_years years after the current date.'),
607 'where' => 'civicrm_custom_field.end_date_years',
608 'table_name' => 'civicrm_custom_field',
609 'entity' => 'CustomField',
610 'bao' => 'CRM_Core_BAO_CustomField',
615 'name' => 'date_format',
616 'type' => CRM_Utils_Type
::T_STRING
,
617 'title' => ts('Field Data Format'),
618 'description' => ts('date format for custom date'),
620 'size' => CRM_Utils_Type
::BIG
,
621 'where' => 'civicrm_custom_field.date_format',
622 'table_name' => 'civicrm_custom_field',
623 'entity' => 'CustomField',
624 'bao' => 'CRM_Core_BAO_CustomField',
626 'pseudoconstant' => [
627 'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats',
632 'name' => 'time_format',
633 'type' => CRM_Utils_Type
::T_INT
,
634 'title' => ts('Field Time Format'),
635 'description' => ts('time format for custom date'),
636 'where' => 'civicrm_custom_field.time_format',
637 'table_name' => 'civicrm_custom_field',
638 'entity' => 'CustomField',
639 'bao' => 'CRM_Core_BAO_CustomField',
641 'pseudoconstant' => [
642 'callback' => 'CRM_Core_SelectValues::getTimeFormats',
647 'name' => 'note_columns',
648 'type' => CRM_Utils_Type
::T_INT
,
649 'title' => ts('Field Note Columns'),
650 'description' => ts('Number of columns in Note Field'),
651 'where' => 'civicrm_custom_field.note_columns',
652 'table_name' => 'civicrm_custom_field',
653 'entity' => 'CustomField',
654 'bao' => 'CRM_Core_BAO_CustomField',
659 'name' => 'note_rows',
660 'type' => CRM_Utils_Type
::T_INT
,
661 'title' => ts('Field Note Rows'),
662 'description' => ts('Number of rows in Note Field'),
663 'where' => 'civicrm_custom_field.note_rows',
664 'table_name' => 'civicrm_custom_field',
665 'entity' => 'CustomField',
666 'bao' => 'CRM_Core_BAO_CustomField',
671 'name' => 'column_name',
672 'type' => CRM_Utils_Type
::T_STRING
,
673 'title' => ts('Field Column Name'),
674 'description' => ts('Name of the column that holds the values for this field.'),
676 'size' => CRM_Utils_Type
::HUGE
,
677 'where' => 'civicrm_custom_field.column_name',
678 'table_name' => 'civicrm_custom_field',
679 'entity' => 'CustomField',
680 'bao' => 'CRM_Core_BAO_CustomField',
684 'option_group_id' => [
685 'name' => 'option_group_id',
686 'type' => CRM_Utils_Type
::T_INT
,
687 'title' => ts('Field Option Group'),
688 'description' => ts('For elements with options, the option group id that is used'),
689 'where' => 'civicrm_custom_field.option_group_id',
690 'table_name' => 'civicrm_custom_field',
691 'entity' => 'CustomField',
692 'bao' => 'CRM_Core_BAO_CustomField',
694 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
695 'pseudoconstant' => [
696 'table' => 'civicrm_option_group',
698 'labelColumn' => 'title',
703 'name' => 'serialize',
704 'type' => CRM_Utils_Type
::T_INT
,
705 'title' => ts('Serialize'),
706 'description' => ts('Serialization method - a non-zero value indicates a multi-valued field.'),
708 'where' => 'civicrm_custom_field.serialize',
710 'table_name' => 'civicrm_custom_field',
711 'entity' => 'CustomField',
712 'bao' => 'CRM_Core_BAO_CustomField',
714 'pseudoconstant' => [
715 'callback' => 'CRM_Core_SelectValues::fieldSerialization',
721 'type' => CRM_Utils_Type
::T_STRING
,
722 'title' => ts('Field Filter'),
723 'description' => ts('Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.'),
725 'size' => CRM_Utils_Type
::HUGE
,
726 'where' => 'civicrm_custom_field.filter',
727 'table_name' => 'civicrm_custom_field',
728 'entity' => 'CustomField',
729 'bao' => 'CRM_Core_BAO_CustomField',
734 'name' => 'in_selector',
735 'type' => CRM_Utils_Type
::T_BOOLEAN
,
736 'title' => ts('Field Display'),
737 'description' => ts('Should the multi-record custom field values be displayed in tab table listing'),
738 'where' => 'civicrm_custom_field.in_selector',
740 'table_name' => 'civicrm_custom_field',
741 'entity' => 'CustomField',
742 'bao' => 'CRM_Core_BAO_CustomField',
747 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
749 return Civi
::$statics[__CLASS__
]['fields'];
753 * Return a mapping from field-name to the corresponding key (as used in fields()).
756 * Array(string $name => string $uniqueName).
758 public static function &fieldKeys() {
759 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
760 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
762 return Civi
::$statics[__CLASS__
]['fieldKeys'];
766 * Returns the names of this table
770 public static function getTableName() {
771 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
775 * Returns if this table needs to be logged
779 public function getLog() {
784 * Returns the list of fields that can be imported
786 * @param bool $prefix
790 public static function &import($prefix = FALSE) {
791 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'custom_field', $prefix, []);
796 * Returns the list of fields that can be exported
798 * @param bool $prefix
802 public static function &export($prefix = FALSE) {
803 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'custom_field', $prefix, []);
808 * Returns the list of indices
810 * @param bool $localize
814 public static function indices($localize = TRUE) {
816 'UI_label_custom_group_id' => [
817 'name' => 'UI_label_custom_group_id',
820 1 => 'custom_group_id',
822 'localizable' => TRUE,
824 'sig' => 'civicrm_custom_field::1::label::custom_group_id',
826 'UI_name_custom_group_id' => [
827 'name' => 'UI_name_custom_group_id',
830 1 => 'custom_group_id',
832 'localizable' => FALSE,
834 'sig' => 'civicrm_custom_field::1::name::custom_group_id',
837 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;