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:3a8f6978ec00d7e2cff93f2915ac1f48)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = TRUE;
34 * Unique Custom Field ID
41 * FK to civicrm_custom_group.
45 public $custom_group_id;
48 * Variable name/programmatic handle for this group.
55 * Text for form field label (also friendly name for administering this custom property).
62 * Controls location of data storage in extended_data table.
69 * HTML types plus several built-in extended types.
76 * Use form_options.is_default for field_types which use options.
80 public $default_value;
83 * Is a value required for this property.
90 * Is this property searchable.
94 public $is_searchable;
97 * Is this property range searchable.
101 public $is_search_range;
104 * Controls field display order within an extended property group.
111 * Description and/or help text to display before this field.
118 * Description and/or help text to display after this field.
125 * Optional format instructions for specific field types, like date types.
132 * Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes
139 * Optional scripting attributes for field.
146 * Is this property active?
153 * Is this property set by PHP Code? A code field is viewable but not editable
160 * number of options per line for checkbox and radio
164 public $options_per_line;
167 * field length if alphanumeric
174 * Date may be up to start_date_years years prior to the current date.
178 public $start_date_years;
181 * Date may be up to end_date_years years after the current date.
185 public $end_date_years;
188 * date format for custom date
195 * time format for custom date
202 * Number of columns in Note Field
206 public $note_columns;
209 * Number of rows in Note Field
216 * Name of the column that holds the values for this field.
223 * For elements with options, the option group id that is used
227 public $option_group_id;
230 * Serialization method - a non-zero value indicates a multi-valued field.
237 * Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.
244 * Should the multi-record custom field values be displayed in tab table listing
253 public function __construct() {
254 $this->__table
= 'civicrm_custom_field';
255 parent
::__construct();
259 * Returns localized title of this entity.
261 * @param bool $plural
262 * Whether to return the plural version of the title.
264 public static function getEntityTitle($plural = FALSE) {
265 return $plural ?
ts('Custom Fields') : ts('Custom Field');
269 * Returns foreign keys and entity references.
272 * [CRM_Core_Reference_Interface]
274 public static function getReferenceColumns() {
275 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
276 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
277 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'custom_group_id', 'civicrm_custom_group', 'id');
278 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'option_group_id', 'civicrm_option_group', 'id');
279 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
281 return Civi
::$statics[__CLASS__
]['links'];
285 * Returns all the column names of this table
289 public static function &fields() {
290 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
291 Civi
::$statics[__CLASS__
]['fields'] = [
294 'type' => CRM_Utils_Type
::T_INT
,
295 'title' => ts('Custom Field ID'),
296 'description' => ts('Unique Custom Field ID'),
298 'where' => 'civicrm_custom_field.id',
299 'table_name' => 'civicrm_custom_field',
300 'entity' => 'CustomField',
301 'bao' => 'CRM_Core_BAO_CustomField',
305 'custom_group_id' => [
306 'name' => 'custom_group_id',
307 'type' => CRM_Utils_Type
::T_INT
,
308 'title' => ts('Custom Group'),
309 'description' => ts('FK to civicrm_custom_group.'),
311 'where' => 'civicrm_custom_field.custom_group_id',
312 'table_name' => 'civicrm_custom_field',
313 'entity' => 'CustomField',
314 'bao' => 'CRM_Core_BAO_CustomField',
316 'FKClassName' => 'CRM_Core_DAO_CustomGroup',
320 'pseudoconstant' => [
321 'table' => 'civicrm_custom_group',
323 'labelColumn' => 'title',
329 'type' => CRM_Utils_Type
::T_STRING
,
330 'title' => ts('Custom Field Name'),
331 'description' => ts('Variable name/programmatic handle for this group.'),
333 'size' => CRM_Utils_Type
::BIG
,
334 'where' => 'civicrm_custom_field.name',
335 'table_name' => 'civicrm_custom_field',
336 'entity' => 'CustomField',
337 'bao' => 'CRM_Core_BAO_CustomField',
343 'type' => CRM_Utils_Type
::T_STRING
,
344 'title' => ts('Custom Field Label'),
345 'description' => ts('Text for form field label (also friendly name for administering this custom property).'),
348 'size' => CRM_Utils_Type
::HUGE
,
349 'where' => 'civicrm_custom_field.label',
350 'table_name' => 'civicrm_custom_field',
351 'entity' => 'CustomField',
352 'bao' => 'CRM_Core_BAO_CustomField',
357 'name' => 'data_type',
358 'type' => CRM_Utils_Type
::T_STRING
,
359 'title' => ts('Custom Field Data Type'),
360 'description' => ts('Controls location of data storage in extended_data table.'),
363 'size' => CRM_Utils_Type
::TWELVE
,
364 'where' => 'civicrm_custom_field.data_type',
365 'table_name' => 'civicrm_custom_field',
366 'entity' => 'CustomField',
367 'bao' => 'CRM_Core_BAO_CustomField',
371 'label' => ts("Data Type"),
373 'pseudoconstant' => [
374 'callback' => 'CRM_Core_BAO_CustomField::dataType',
379 'name' => 'html_type',
380 'type' => CRM_Utils_Type
::T_STRING
,
381 'title' => ts('Custom Field HTML Type'),
382 'description' => ts('HTML types plus several built-in extended types.'),
385 'size' => CRM_Utils_Type
::MEDIUM
,
386 'where' => 'civicrm_custom_field.html_type',
387 'table_name' => 'civicrm_custom_field',
388 'entity' => 'CustomField',
389 'bao' => 'CRM_Core_BAO_CustomField',
393 'label' => ts("Field Input Type"),
395 'pseudoconstant' => [
396 'callback' => 'CRM_Core_SelectValues::customHtmlType',
401 'name' => 'default_value',
402 'type' => CRM_Utils_Type
::T_STRING
,
403 'title' => ts('Custom Field Default'),
404 'description' => ts('Use form_options.is_default for field_types which use options.'),
406 'size' => CRM_Utils_Type
::HUGE
,
407 'where' => 'civicrm_custom_field.default_value',
408 'table_name' => 'civicrm_custom_field',
409 'entity' => 'CustomField',
410 'bao' => 'CRM_Core_BAO_CustomField',
415 'name' => 'is_required',
416 'type' => CRM_Utils_Type
::T_BOOLEAN
,
417 'title' => ts('Custom Field Is Required?'),
418 'description' => ts('Is a value required for this property.'),
419 'where' => 'civicrm_custom_field.is_required',
421 'table_name' => 'civicrm_custom_field',
422 'entity' => 'CustomField',
423 'bao' => 'CRM_Core_BAO_CustomField',
428 'name' => 'is_searchable',
429 'type' => CRM_Utils_Type
::T_BOOLEAN
,
430 'title' => ts('Allow Searching on Field?'),
431 'description' => ts('Is this property searchable.'),
432 'where' => 'civicrm_custom_field.is_searchable',
434 'table_name' => 'civicrm_custom_field',
435 'entity' => 'CustomField',
436 'bao' => 'CRM_Core_BAO_CustomField',
440 'is_search_range' => [
441 'name' => 'is_search_range',
442 'type' => CRM_Utils_Type
::T_BOOLEAN
,
443 'title' => ts('Search as a Range'),
444 'description' => ts('Is this property range searchable.'),
445 'where' => 'civicrm_custom_field.is_search_range',
447 'table_name' => 'civicrm_custom_field',
448 'entity' => 'CustomField',
449 'bao' => 'CRM_Core_BAO_CustomField',
455 'type' => CRM_Utils_Type
::T_INT
,
456 'title' => ts('Order'),
457 'description' => ts('Controls field display order within an extended property group.'),
459 'where' => 'civicrm_custom_field.weight',
461 'table_name' => 'civicrm_custom_field',
462 'entity' => 'CustomField',
463 'bao' => 'CRM_Core_BAO_CustomField',
468 'name' => 'help_pre',
469 'type' => CRM_Utils_Type
::T_TEXT
,
470 'title' => ts('Custom Field Pre Text'),
471 'description' => ts('Description and/or help text to display before this field.'),
472 'where' => 'civicrm_custom_field.help_pre',
473 'table_name' => 'civicrm_custom_field',
474 'entity' => 'CustomField',
475 'bao' => 'CRM_Core_BAO_CustomField',
480 'name' => 'help_post',
481 'type' => CRM_Utils_Type
::T_TEXT
,
482 'title' => ts('Custom Field Post Text'),
483 'description' => ts('Description and/or help text to display after this field.'),
484 'where' => 'civicrm_custom_field.help_post',
485 'table_name' => 'civicrm_custom_field',
486 'entity' => 'CustomField',
487 'bao' => 'CRM_Core_BAO_CustomField',
493 'type' => CRM_Utils_Type
::T_STRING
,
494 'title' => ts('Custom Field Formatting'),
495 'description' => ts('Optional format instructions for specific field types, like date types.'),
497 'size' => CRM_Utils_Type
::BIG
,
498 'where' => 'civicrm_custom_field.mask',
499 'table_name' => 'civicrm_custom_field',
500 'entity' => 'CustomField',
501 'bao' => 'CRM_Core_BAO_CustomField',
506 'name' => 'attributes',
507 'type' => CRM_Utils_Type
::T_STRING
,
508 'title' => ts('Custom Field Attributes'),
509 'description' => ts('Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes'),
511 'size' => CRM_Utils_Type
::HUGE
,
512 'where' => 'civicrm_custom_field.attributes',
513 'table_name' => 'civicrm_custom_field',
514 'entity' => 'CustomField',
515 'bao' => 'CRM_Core_BAO_CustomField',
520 'name' => 'javascript',
521 'type' => CRM_Utils_Type
::T_STRING
,
522 'title' => ts('Custom Field Javascript'),
523 'description' => ts('Optional scripting attributes for field.'),
525 'size' => CRM_Utils_Type
::HUGE
,
526 'where' => 'civicrm_custom_field.javascript',
527 'table_name' => 'civicrm_custom_field',
528 'entity' => 'CustomField',
529 'bao' => 'CRM_Core_BAO_CustomField',
534 'name' => 'is_active',
535 'type' => CRM_Utils_Type
::T_BOOLEAN
,
536 'title' => ts('Custom Field Is Active?'),
537 'description' => ts('Is this property active?'),
538 'where' => 'civicrm_custom_field.is_active',
540 'table_name' => 'civicrm_custom_field',
541 'entity' => 'CustomField',
542 'bao' => 'CRM_Core_BAO_CustomField',
548 'type' => CRM_Utils_Type
::T_BOOLEAN
,
549 'title' => ts('Field is Viewable'),
550 'description' => ts('Is this property set by PHP Code? A code field is viewable but not editable'),
551 'where' => 'civicrm_custom_field.is_view',
553 'table_name' => 'civicrm_custom_field',
554 'entity' => 'CustomField',
555 'bao' => 'CRM_Core_BAO_CustomField',
559 'options_per_line' => [
560 'name' => 'options_per_line',
561 'type' => CRM_Utils_Type
::T_INT
,
562 'title' => ts('Field Options Per Line'),
563 'description' => ts('number of options per line for checkbox and radio'),
564 'where' => 'civicrm_custom_field.options_per_line',
565 'table_name' => 'civicrm_custom_field',
566 'entity' => 'CustomField',
567 'bao' => 'CRM_Core_BAO_CustomField',
572 'name' => 'text_length',
573 'type' => CRM_Utils_Type
::T_INT
,
574 'title' => ts('Field Length'),
575 'description' => ts('field length if alphanumeric'),
576 'where' => 'civicrm_custom_field.text_length',
577 'table_name' => 'civicrm_custom_field',
578 'entity' => 'CustomField',
579 'bao' => 'CRM_Core_BAO_CustomField',
583 'start_date_years' => [
584 'name' => 'start_date_years',
585 'type' => CRM_Utils_Type
::T_INT
,
586 'title' => ts('Field Start Date'),
587 'description' => ts('Date may be up to start_date_years years prior to the current date.'),
588 'where' => 'civicrm_custom_field.start_date_years',
589 'table_name' => 'civicrm_custom_field',
590 'entity' => 'CustomField',
591 'bao' => 'CRM_Core_BAO_CustomField',
595 'end_date_years' => [
596 'name' => 'end_date_years',
597 'type' => CRM_Utils_Type
::T_INT
,
598 'title' => ts('Field End Date'),
599 'description' => ts('Date may be up to end_date_years years after the current date.'),
600 'where' => 'civicrm_custom_field.end_date_years',
601 'table_name' => 'civicrm_custom_field',
602 'entity' => 'CustomField',
603 'bao' => 'CRM_Core_BAO_CustomField',
608 'name' => 'date_format',
609 'type' => CRM_Utils_Type
::T_STRING
,
610 'title' => ts('Field Data Format'),
611 'description' => ts('date format for custom date'),
613 'size' => CRM_Utils_Type
::BIG
,
614 'where' => 'civicrm_custom_field.date_format',
615 'table_name' => 'civicrm_custom_field',
616 'entity' => 'CustomField',
617 'bao' => 'CRM_Core_BAO_CustomField',
619 'pseudoconstant' => [
620 'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats',
625 'name' => 'time_format',
626 'type' => CRM_Utils_Type
::T_INT
,
627 'title' => ts('Field Time Format'),
628 'description' => ts('time format for custom date'),
629 'where' => 'civicrm_custom_field.time_format',
630 'table_name' => 'civicrm_custom_field',
631 'entity' => 'CustomField',
632 'bao' => 'CRM_Core_BAO_CustomField',
634 'pseudoconstant' => [
635 'callback' => 'CRM_Core_SelectValues::getTimeFormats',
640 'name' => 'note_columns',
641 'type' => CRM_Utils_Type
::T_INT
,
642 'title' => ts('Field Note Columns'),
643 'description' => ts('Number of columns in Note Field'),
644 'where' => 'civicrm_custom_field.note_columns',
645 'table_name' => 'civicrm_custom_field',
646 'entity' => 'CustomField',
647 'bao' => 'CRM_Core_BAO_CustomField',
652 'name' => 'note_rows',
653 'type' => CRM_Utils_Type
::T_INT
,
654 'title' => ts('Field Note Rows'),
655 'description' => ts('Number of rows in Note Field'),
656 'where' => 'civicrm_custom_field.note_rows',
657 'table_name' => 'civicrm_custom_field',
658 'entity' => 'CustomField',
659 'bao' => 'CRM_Core_BAO_CustomField',
664 'name' => 'column_name',
665 'type' => CRM_Utils_Type
::T_STRING
,
666 'title' => ts('Field Column Name'),
667 'description' => ts('Name of the column that holds the values for this field.'),
669 'size' => CRM_Utils_Type
::HUGE
,
670 'where' => 'civicrm_custom_field.column_name',
671 'table_name' => 'civicrm_custom_field',
672 'entity' => 'CustomField',
673 'bao' => 'CRM_Core_BAO_CustomField',
677 'option_group_id' => [
678 'name' => 'option_group_id',
679 'type' => CRM_Utils_Type
::T_INT
,
680 'title' => ts('Field Option Group'),
681 'description' => ts('For elements with options, the option group id that is used'),
682 'where' => 'civicrm_custom_field.option_group_id',
683 'table_name' => 'civicrm_custom_field',
684 'entity' => 'CustomField',
685 'bao' => 'CRM_Core_BAO_CustomField',
687 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
688 'pseudoconstant' => [
689 'table' => 'civicrm_option_group',
691 'labelColumn' => 'title',
696 'name' => 'serialize',
697 'type' => CRM_Utils_Type
::T_INT
,
698 'title' => ts('Serialize'),
699 'description' => ts('Serialization method - a non-zero value indicates a multi-valued field.'),
701 'where' => 'civicrm_custom_field.serialize',
703 'table_name' => 'civicrm_custom_field',
704 'entity' => 'CustomField',
705 'bao' => 'CRM_Core_BAO_CustomField',
707 'pseudoconstant' => [
708 'callback' => 'CRM_Core_SelectValues::fieldSerialization',
714 'type' => CRM_Utils_Type
::T_STRING
,
715 'title' => ts('Field Filter'),
716 'description' => ts('Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.'),
718 'size' => CRM_Utils_Type
::HUGE
,
719 'where' => 'civicrm_custom_field.filter',
720 'table_name' => 'civicrm_custom_field',
721 'entity' => 'CustomField',
722 'bao' => 'CRM_Core_BAO_CustomField',
727 'name' => 'in_selector',
728 'type' => CRM_Utils_Type
::T_BOOLEAN
,
729 'title' => ts('Field Display'),
730 'description' => ts('Should the multi-record custom field values be displayed in tab table listing'),
731 'where' => 'civicrm_custom_field.in_selector',
733 'table_name' => 'civicrm_custom_field',
734 'entity' => 'CustomField',
735 'bao' => 'CRM_Core_BAO_CustomField',
740 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
742 return Civi
::$statics[__CLASS__
]['fields'];
746 * Return a mapping from field-name to the corresponding key (as used in fields()).
749 * Array(string $name => string $uniqueName).
751 public static function &fieldKeys() {
752 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
753 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
755 return Civi
::$statics[__CLASS__
]['fieldKeys'];
759 * Returns the names of this table
763 public static function getTableName() {
764 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
768 * Returns if this table needs to be logged
772 public function getLog() {
777 * Returns the list of fields that can be imported
779 * @param bool $prefix
783 public static function &import($prefix = FALSE) {
784 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'custom_field', $prefix, []);
789 * Returns the list of fields that can be exported
791 * @param bool $prefix
795 public static function &export($prefix = FALSE) {
796 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'custom_field', $prefix, []);
801 * Returns the list of indices
803 * @param bool $localize
807 public static function indices($localize = TRUE) {
809 'UI_label_custom_group_id' => [
810 'name' => 'UI_label_custom_group_id',
813 1 => 'custom_group_id',
815 'localizable' => TRUE,
817 'sig' => 'civicrm_custom_field::1::label::custom_group_id',
819 'UI_name_custom_group_id' => [
820 'name' => 'UI_name_custom_group_id',
823 1 => 'custom_group_id',
825 'localizable' => FALSE,
827 'sig' => 'civicrm_custom_field::1::name::custom_group_id',
830 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;