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:b53a928be3c87ec7da4f88da3ec825b8)
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 field.
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',
316 'custom_group_id' => [
317 'name' => 'custom_group_id',
318 'type' => CRM_Utils_Type
::T_INT
,
319 'title' => ts('Custom Group ID'),
320 'description' => ts('FK to civicrm_custom_group.'),
322 'where' => 'civicrm_custom_field.custom_group_id',
323 'table_name' => 'civicrm_custom_field',
324 'entity' => 'CustomField',
325 'bao' => 'CRM_Core_BAO_CustomField',
327 'FKClassName' => 'CRM_Core_DAO_CustomGroup',
330 'label' => ts("Custom Group"),
332 'pseudoconstant' => [
333 'table' => 'civicrm_custom_group',
335 'labelColumn' => 'title',
341 'type' => CRM_Utils_Type
::T_STRING
,
342 'title' => ts('Custom Field Name'),
343 'description' => ts('Variable name/programmatic handle for this field.'),
345 'size' => CRM_Utils_Type
::BIG
,
346 'where' => 'civicrm_custom_field.name',
347 'table_name' => 'civicrm_custom_field',
348 'entity' => 'CustomField',
349 'bao' => 'CRM_Core_BAO_CustomField',
355 'type' => CRM_Utils_Type
::T_STRING
,
356 'title' => ts('Custom Field Label'),
357 'description' => ts('Text for form field label (also friendly name for administering this custom property).'),
360 'size' => CRM_Utils_Type
::HUGE
,
361 'where' => 'civicrm_custom_field.label',
362 'table_name' => 'civicrm_custom_field',
363 'entity' => 'CustomField',
364 'bao' => 'CRM_Core_BAO_CustomField',
369 'name' => 'data_type',
370 'type' => CRM_Utils_Type
::T_STRING
,
371 'title' => ts('Data Type'),
372 'description' => ts('Controls location of data storage in extended_data table.'),
375 'size' => CRM_Utils_Type
::TWELVE
,
376 'where' => 'civicrm_custom_field.data_type',
377 'table_name' => 'civicrm_custom_field',
378 'entity' => 'CustomField',
379 'bao' => 'CRM_Core_BAO_CustomField',
383 'label' => ts("Data Type"),
385 'pseudoconstant' => [
386 'callback' => 'CRM_Core_BAO_CustomField::dataType',
391 'name' => 'html_type',
392 'type' => CRM_Utils_Type
::T_STRING
,
393 'title' => ts('HTML Type'),
394 'description' => ts('HTML types plus several built-in extended types.'),
397 'size' => CRM_Utils_Type
::MEDIUM
,
398 'where' => 'civicrm_custom_field.html_type',
399 'table_name' => 'civicrm_custom_field',
400 'entity' => 'CustomField',
401 'bao' => 'CRM_Core_BAO_CustomField',
405 'label' => ts("Field Input Type"),
407 'pseudoconstant' => [
408 'callback' => 'CRM_Core_SelectValues::customHtmlType',
413 'name' => 'default_value',
414 'type' => CRM_Utils_Type
::T_STRING
,
415 'title' => ts('Custom Field Default'),
416 'description' => ts('Use form_options.is_default for field_types which use options.'),
418 'size' => CRM_Utils_Type
::HUGE
,
419 'where' => 'civicrm_custom_field.default_value',
420 'table_name' => 'civicrm_custom_field',
421 'entity' => 'CustomField',
422 'bao' => 'CRM_Core_BAO_CustomField',
427 'name' => 'is_required',
428 'type' => CRM_Utils_Type
::T_BOOLEAN
,
429 'title' => ts('Custom Field Is Required?'),
430 'description' => ts('Is a value required for this property.'),
431 'where' => 'civicrm_custom_field.is_required',
433 'table_name' => 'civicrm_custom_field',
434 'entity' => 'CustomField',
435 'bao' => 'CRM_Core_BAO_CustomField',
440 'name' => 'is_searchable',
441 'type' => CRM_Utils_Type
::T_BOOLEAN
,
442 'title' => ts('Allow Searching on Field?'),
443 'description' => ts('Is this property searchable.'),
444 'where' => 'civicrm_custom_field.is_searchable',
446 'table_name' => 'civicrm_custom_field',
447 'entity' => 'CustomField',
448 'bao' => 'CRM_Core_BAO_CustomField',
452 'is_search_range' => [
453 'name' => 'is_search_range',
454 'type' => CRM_Utils_Type
::T_BOOLEAN
,
455 'title' => ts('Search as a Range'),
456 'description' => ts('Is this property range searchable.'),
457 'where' => 'civicrm_custom_field.is_search_range',
459 'table_name' => 'civicrm_custom_field',
460 'entity' => 'CustomField',
461 'bao' => 'CRM_Core_BAO_CustomField',
467 'type' => CRM_Utils_Type
::T_INT
,
468 'title' => ts('Order'),
469 'description' => ts('Controls field display order within an extended property group.'),
471 'where' => 'civicrm_custom_field.weight',
473 'table_name' => 'civicrm_custom_field',
474 'entity' => 'CustomField',
475 'bao' => 'CRM_Core_BAO_CustomField',
480 'name' => 'help_pre',
481 'type' => CRM_Utils_Type
::T_TEXT
,
482 'title' => ts('Custom Field Pre Text'),
483 'description' => ts('Description and/or help text to display before this field.'),
484 'where' => 'civicrm_custom_field.help_pre',
485 'table_name' => 'civicrm_custom_field',
486 'entity' => 'CustomField',
487 'bao' => 'CRM_Core_BAO_CustomField',
492 'name' => 'help_post',
493 'type' => CRM_Utils_Type
::T_TEXT
,
494 'title' => ts('Custom Field Post Text'),
495 'description' => ts('Description and/or help text to display after this field.'),
496 'where' => 'civicrm_custom_field.help_post',
497 'table_name' => 'civicrm_custom_field',
498 'entity' => 'CustomField',
499 'bao' => 'CRM_Core_BAO_CustomField',
505 'type' => CRM_Utils_Type
::T_STRING
,
506 'title' => ts('Custom Field Formatting'),
507 'description' => ts('Optional format instructions for specific field types, like date types.'),
509 'size' => CRM_Utils_Type
::BIG
,
510 'where' => 'civicrm_custom_field.mask',
511 'table_name' => 'civicrm_custom_field',
512 'entity' => 'CustomField',
513 'bao' => 'CRM_Core_BAO_CustomField',
518 'name' => 'attributes',
519 'type' => CRM_Utils_Type
::T_STRING
,
520 'title' => ts('Custom Field Attributes'),
521 'description' => ts('Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes'),
523 'size' => CRM_Utils_Type
::HUGE
,
524 'where' => 'civicrm_custom_field.attributes',
525 'table_name' => 'civicrm_custom_field',
526 'entity' => 'CustomField',
527 'bao' => 'CRM_Core_BAO_CustomField',
532 'name' => 'javascript',
533 'type' => CRM_Utils_Type
::T_STRING
,
534 'title' => ts('Custom Field Javascript'),
535 'description' => ts('Optional scripting attributes for field.'),
537 'size' => CRM_Utils_Type
::HUGE
,
538 'where' => 'civicrm_custom_field.javascript',
539 'table_name' => 'civicrm_custom_field',
540 'entity' => 'CustomField',
541 'bao' => 'CRM_Core_BAO_CustomField',
546 'name' => 'is_active',
547 'type' => CRM_Utils_Type
::T_BOOLEAN
,
548 'title' => ts('Custom Field Is Active?'),
549 'description' => ts('Is this property active?'),
550 'where' => 'civicrm_custom_field.is_active',
552 'table_name' => 'civicrm_custom_field',
553 'entity' => 'CustomField',
554 'bao' => 'CRM_Core_BAO_CustomField',
560 'type' => CRM_Utils_Type
::T_BOOLEAN
,
561 'title' => ts('Field is Viewable'),
562 'description' => ts('Is this property set by PHP Code? A code field is viewable but not editable'),
563 'where' => 'civicrm_custom_field.is_view',
565 'table_name' => 'civicrm_custom_field',
566 'entity' => 'CustomField',
567 'bao' => 'CRM_Core_BAO_CustomField',
571 'options_per_line' => [
572 'name' => 'options_per_line',
573 'type' => CRM_Utils_Type
::T_INT
,
574 'title' => ts('Field Options Per Line'),
575 'description' => ts('number of options per line for checkbox and radio'),
576 'where' => 'civicrm_custom_field.options_per_line',
577 'table_name' => 'civicrm_custom_field',
578 'entity' => 'CustomField',
579 'bao' => 'CRM_Core_BAO_CustomField',
584 'name' => 'text_length',
585 'type' => CRM_Utils_Type
::T_INT
,
586 'title' => ts('Field Length'),
587 'description' => ts('field length if alphanumeric'),
588 'where' => 'civicrm_custom_field.text_length',
589 'table_name' => 'civicrm_custom_field',
590 'entity' => 'CustomField',
591 'bao' => 'CRM_Core_BAO_CustomField',
595 'start_date_years' => [
596 'name' => 'start_date_years',
597 'type' => CRM_Utils_Type
::T_INT
,
598 'title' => ts('Field Start Date'),
599 'description' => ts('Date may be up to start_date_years years prior to the current date.'),
600 'where' => 'civicrm_custom_field.start_date_years',
601 'table_name' => 'civicrm_custom_field',
602 'entity' => 'CustomField',
603 'bao' => 'CRM_Core_BAO_CustomField',
607 'end_date_years' => [
608 'name' => 'end_date_years',
609 'type' => CRM_Utils_Type
::T_INT
,
610 'title' => ts('Field End Date'),
611 'description' => ts('Date may be up to end_date_years years after the current date.'),
612 'where' => 'civicrm_custom_field.end_date_years',
613 'table_name' => 'civicrm_custom_field',
614 'entity' => 'CustomField',
615 'bao' => 'CRM_Core_BAO_CustomField',
620 'name' => 'date_format',
621 'type' => CRM_Utils_Type
::T_STRING
,
622 'title' => ts('Field Data Format'),
623 'description' => ts('date format for custom date'),
625 'size' => CRM_Utils_Type
::BIG
,
626 'where' => 'civicrm_custom_field.date_format',
627 'table_name' => 'civicrm_custom_field',
628 'entity' => 'CustomField',
629 'bao' => 'CRM_Core_BAO_CustomField',
631 'pseudoconstant' => [
632 'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats',
637 'name' => 'time_format',
638 'type' => CRM_Utils_Type
::T_INT
,
639 'title' => ts('Field Time Format'),
640 'description' => ts('time format for custom date'),
641 'where' => 'civicrm_custom_field.time_format',
642 'table_name' => 'civicrm_custom_field',
643 'entity' => 'CustomField',
644 'bao' => 'CRM_Core_BAO_CustomField',
646 'pseudoconstant' => [
647 'callback' => 'CRM_Core_SelectValues::getTimeFormats',
652 'name' => 'note_columns',
653 'type' => CRM_Utils_Type
::T_INT
,
654 'title' => ts('Field Note Columns'),
655 'description' => ts('Number of columns in Note Field'),
656 'where' => 'civicrm_custom_field.note_columns',
657 'table_name' => 'civicrm_custom_field',
658 'entity' => 'CustomField',
659 'bao' => 'CRM_Core_BAO_CustomField',
664 'name' => 'note_rows',
665 'type' => CRM_Utils_Type
::T_INT
,
666 'title' => ts('Field Note Rows'),
667 'description' => ts('Number of rows in Note Field'),
668 'where' => 'civicrm_custom_field.note_rows',
669 'table_name' => 'civicrm_custom_field',
670 'entity' => 'CustomField',
671 'bao' => 'CRM_Core_BAO_CustomField',
676 'name' => 'column_name',
677 'type' => CRM_Utils_Type
::T_STRING
,
678 'title' => ts('Field Column Name'),
679 'description' => ts('Name of the column that holds the values for this field.'),
681 'size' => CRM_Utils_Type
::HUGE
,
682 'where' => 'civicrm_custom_field.column_name',
683 'table_name' => 'civicrm_custom_field',
684 'entity' => 'CustomField',
685 'bao' => 'CRM_Core_BAO_CustomField',
689 'option_group_id' => [
690 'name' => 'option_group_id',
691 'type' => CRM_Utils_Type
::T_INT
,
692 'title' => ts('Field Option Group ID'),
693 'description' => ts('For elements with options, the option group id that is used'),
694 'where' => 'civicrm_custom_field.option_group_id',
695 'table_name' => 'civicrm_custom_field',
696 'entity' => 'CustomField',
697 'bao' => 'CRM_Core_BAO_CustomField',
699 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
701 'label' => ts("Field Option Group"),
703 'pseudoconstant' => [
704 'table' => 'civicrm_option_group',
706 'labelColumn' => 'title',
711 'name' => 'serialize',
712 'type' => CRM_Utils_Type
::T_INT
,
713 'title' => ts('Serialize'),
714 'description' => ts('Serialization method - a non-zero value indicates a multi-valued field.'),
716 'where' => 'civicrm_custom_field.serialize',
718 'table_name' => 'civicrm_custom_field',
719 'entity' => 'CustomField',
720 'bao' => 'CRM_Core_BAO_CustomField',
722 'pseudoconstant' => [
723 'callback' => 'CRM_Core_SelectValues::fieldSerialization',
729 'type' => CRM_Utils_Type
::T_STRING
,
730 'title' => ts('Field Filter'),
731 'description' => ts('Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.'),
733 'size' => CRM_Utils_Type
::HUGE
,
734 'where' => 'civicrm_custom_field.filter',
735 'table_name' => 'civicrm_custom_field',
736 'entity' => 'CustomField',
737 'bao' => 'CRM_Core_BAO_CustomField',
742 'name' => 'in_selector',
743 'type' => CRM_Utils_Type
::T_BOOLEAN
,
744 'title' => ts('Field Display'),
745 'description' => ts('Should the multi-record custom field values be displayed in tab table listing'),
746 'where' => 'civicrm_custom_field.in_selector',
748 'table_name' => 'civicrm_custom_field',
749 'entity' => 'CustomField',
750 'bao' => 'CRM_Core_BAO_CustomField',
755 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
757 return Civi
::$statics[__CLASS__
]['fields'];
761 * Return a mapping from field-name to the corresponding key (as used in fields()).
764 * Array(string $name => string $uniqueName).
766 public static function &fieldKeys() {
767 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
768 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
770 return Civi
::$statics[__CLASS__
]['fieldKeys'];
774 * Returns the names of this table
778 public static function getTableName() {
779 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
783 * Returns if this table needs to be logged
787 public function getLog() {
792 * Returns the list of fields that can be imported
794 * @param bool $prefix
798 public static function &import($prefix = FALSE) {
799 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'custom_field', $prefix, []);
804 * Returns the list of fields that can be exported
806 * @param bool $prefix
810 public static function &export($prefix = FALSE) {
811 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'custom_field', $prefix, []);
816 * Returns the list of indices
818 * @param bool $localize
822 public static function indices($localize = TRUE) {
824 'UI_label_custom_group_id' => [
825 'name' => 'UI_label_custom_group_id',
828 1 => 'custom_group_id',
830 'localizable' => TRUE,
832 'sig' => 'civicrm_custom_field::1::label::custom_group_id',
834 'UI_name_custom_group_id' => [
835 'name' => 'UI_name_custom_group_id',
838 1 => 'custom_group_id',
840 'localizable' => FALSE,
842 'sig' => 'civicrm_custom_field::1::name::custom_group_id',
845 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;