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:52ca62aae191d0b8f9ec8bf5ad5595d1)
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 * Paths for accessing this entity in the UI.
45 protected static $_paths = [
46 'add' => 'civicrm/admin/custom/group/field/add?reset=1&action=add&gid=[custom_group_id]',
47 'update' => 'civicrm/admin/custom/group/field/update?action=update&reset=1&id=[id]&gid=[custom_group_id]',
48 'preview' => 'civicrm/admin/custom/group/preview?reset=1&fid=[id]',
49 'delete' => 'civicrm/admin/custom/group/field/delete?reset=1&id=[id]',
50 'move' => 'civicrm/admin/custom/group/field/move?reset=1&fid=[id]',
54 * Unique Custom Field ID
56 * @var int|string|null
57 * (SQL type: int unsigned)
58 * Note that values will be retrieved from the database as a string.
63 * FK to civicrm_custom_group.
66 * (SQL type: int unsigned)
67 * Note that values will be retrieved from the database as a string.
69 public $custom_group_id;
72 * Variable name/programmatic handle for this field.
75 * (SQL type: varchar(64))
76 * Note that values will be retrieved from the database as a string.
81 * Text for form field label (also friendly name for administering this custom property).
84 * (SQL type: varchar(255))
85 * Note that values will be retrieved from the database as a string.
90 * Controls location of data storage in extended_data table.
93 * (SQL type: varchar(16))
94 * Note that values will be retrieved from the database as a string.
99 * HTML types plus several built-in extended types.
102 * (SQL type: varchar(32))
103 * Note that values will be retrieved from the database as a string.
108 * Use form_options.is_default for field_types which use options.
111 * (SQL type: varchar(255))
112 * Note that values will be retrieved from the database as a string.
114 public $default_value;
117 * Is a value required for this property.
120 * (SQL type: tinyint)
121 * Note that values will be retrieved from the database as a string.
126 * Is this property searchable.
129 * (SQL type: tinyint)
130 * Note that values will be retrieved from the database as a string.
132 public $is_searchable;
135 * Is this property range searchable.
138 * (SQL type: tinyint)
139 * Note that values will be retrieved from the database as a string.
141 public $is_search_range;
144 * Controls field display order within an extended property group.
148 * Note that values will be retrieved from the database as a string.
153 * Description and/or help text to display before this field.
157 * Note that values will be retrieved from the database as a string.
162 * Description and/or help text to display after this field.
166 * Note that values will be retrieved from the database as a string.
171 * Optional format instructions for specific field types, like date types.
174 * (SQL type: varchar(64))
175 * Note that values will be retrieved from the database as a string.
180 * Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes
183 * (SQL type: varchar(255))
184 * Note that values will be retrieved from the database as a string.
189 * Optional scripting attributes for field.
192 * (SQL type: varchar(255))
193 * Note that values will be retrieved from the database as a string.
198 * Is this property active?
200 * @var bool|string|null
201 * (SQL type: tinyint)
202 * Note that values will be retrieved from the database as a string.
207 * Is this property set by PHP Code? A code field is viewable but not editable
210 * (SQL type: tinyint)
211 * Note that values will be retrieved from the database as a string.
216 * number of options per line for checkbox and radio
218 * @var int|string|null
219 * (SQL type: int unsigned)
220 * Note that values will be retrieved from the database as a string.
222 public $options_per_line;
225 * field length if alphanumeric
227 * @var int|string|null
228 * (SQL type: int unsigned)
229 * Note that values will be retrieved from the database as a string.
234 * Date may be up to start_date_years years prior to the current date.
236 * @var int|string|null
238 * Note that values will be retrieved from the database as a string.
240 public $start_date_years;
243 * Date may be up to end_date_years years after the current date.
245 * @var int|string|null
247 * Note that values will be retrieved from the database as a string.
249 public $end_date_years;
252 * date format for custom date
255 * (SQL type: varchar(64))
256 * Note that values will be retrieved from the database as a string.
261 * time format for custom date
263 * @var int|string|null
264 * (SQL type: int unsigned)
265 * Note that values will be retrieved from the database as a string.
270 * Number of columns in Note Field
272 * @var int|string|null
273 * (SQL type: int unsigned)
274 * Note that values will be retrieved from the database as a string.
276 public $note_columns;
279 * Number of rows in Note Field
281 * @var int|string|null
282 * (SQL type: int unsigned)
283 * Note that values will be retrieved from the database as a string.
288 * Name of the column that holds the values for this field.
291 * (SQL type: varchar(255))
292 * Note that values will be retrieved from the database as a string.
297 * For elements with options, the option group id that is used
299 * @var int|string|null
300 * (SQL type: int unsigned)
301 * Note that values will be retrieved from the database as a string.
303 public $option_group_id;
306 * Serialization method - a non-zero value indicates a multi-valued field.
309 * (SQL type: int unsigned)
310 * Note that values will be retrieved from the database as a string.
315 * Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.
318 * (SQL type: varchar(255))
319 * Note that values will be retrieved from the database as a string.
324 * Should the multi-record custom field values be displayed in tab table listing
327 * (SQL type: tinyint)
328 * Note that values will be retrieved from the database as a string.
335 public function __construct() {
336 $this->__table
= 'civicrm_custom_field';
337 parent
::__construct();
341 * Returns localized title of this entity.
343 * @param bool $plural
344 * Whether to return the plural version of the title.
346 public static function getEntityTitle($plural = FALSE) {
347 return $plural ?
ts('Custom Fields') : ts('Custom Field');
351 * Returns foreign keys and entity references.
354 * [CRM_Core_Reference_Interface]
356 public static function getReferenceColumns() {
357 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
358 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
359 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'custom_group_id', 'civicrm_custom_group', 'id');
360 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'option_group_id', 'civicrm_option_group', 'id');
361 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
363 return Civi
::$statics[__CLASS__
]['links'];
367 * Returns all the column names of this table
371 public static function &fields() {
372 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
373 Civi
::$statics[__CLASS__
]['fields'] = [
376 'type' => CRM_Utils_Type
::T_INT
,
377 'title' => ts('Custom Field ID'),
378 'description' => ts('Unique Custom Field ID'),
380 'where' => 'civicrm_custom_field.id',
381 'table_name' => 'civicrm_custom_field',
382 'entity' => 'CustomField',
383 'bao' => 'CRM_Core_BAO_CustomField',
391 'custom_group_id' => [
392 'name' => 'custom_group_id',
393 'type' => CRM_Utils_Type
::T_INT
,
394 'title' => ts('Custom Group ID'),
395 'description' => ts('FK to civicrm_custom_group.'),
397 'where' => 'civicrm_custom_field.custom_group_id',
398 'table_name' => 'civicrm_custom_field',
399 'entity' => 'CustomField',
400 'bao' => 'CRM_Core_BAO_CustomField',
402 'FKClassName' => 'CRM_Core_DAO_CustomGroup',
405 'label' => ts("Custom Group"),
407 'pseudoconstant' => [
408 'table' => 'civicrm_custom_group',
410 'labelColumn' => 'title',
416 'type' => CRM_Utils_Type
::T_STRING
,
417 'title' => ts('Custom Field Name'),
418 'description' => ts('Variable name/programmatic handle for this field.'),
420 'size' => CRM_Utils_Type
::BIG
,
421 'where' => 'civicrm_custom_field.name',
422 'table_name' => 'civicrm_custom_field',
423 'entity' => 'CustomField',
424 'bao' => 'CRM_Core_BAO_CustomField',
430 'type' => CRM_Utils_Type
::T_STRING
,
431 'title' => ts('Custom Field Label'),
432 'description' => ts('Text for form field label (also friendly name for administering this custom property).'),
435 'size' => CRM_Utils_Type
::HUGE
,
436 'where' => 'civicrm_custom_field.label',
437 'table_name' => 'civicrm_custom_field',
438 'entity' => 'CustomField',
439 'bao' => 'CRM_Core_BAO_CustomField',
444 'name' => 'data_type',
445 'type' => CRM_Utils_Type
::T_STRING
,
446 'title' => ts('Data Type'),
447 'description' => ts('Controls location of data storage in extended_data table.'),
450 'size' => CRM_Utils_Type
::TWELVE
,
451 'where' => 'civicrm_custom_field.data_type',
452 'table_name' => 'civicrm_custom_field',
453 'entity' => 'CustomField',
454 'bao' => 'CRM_Core_BAO_CustomField',
458 'label' => ts("Data Type"),
460 'pseudoconstant' => [
461 'callback' => 'CRM_Core_BAO_CustomField::dataType',
466 'name' => 'html_type',
467 'type' => CRM_Utils_Type
::T_STRING
,
468 'title' => ts('HTML Type'),
469 'description' => ts('HTML types plus several built-in extended types.'),
472 'size' => CRM_Utils_Type
::MEDIUM
,
473 'where' => 'civicrm_custom_field.html_type',
474 'table_name' => 'civicrm_custom_field',
475 'entity' => 'CustomField',
476 'bao' => 'CRM_Core_BAO_CustomField',
480 'label' => ts("Field Input Type"),
482 'pseudoconstant' => [
483 'callback' => 'CRM_Core_SelectValues::customHtmlType',
488 'name' => 'default_value',
489 'type' => CRM_Utils_Type
::T_STRING
,
490 'title' => ts('Custom Field Default'),
491 'description' => ts('Use form_options.is_default for field_types which use options.'),
493 'size' => CRM_Utils_Type
::HUGE
,
494 'where' => 'civicrm_custom_field.default_value',
495 'table_name' => 'civicrm_custom_field',
496 'entity' => 'CustomField',
497 'bao' => 'CRM_Core_BAO_CustomField',
502 'name' => 'is_required',
503 'type' => CRM_Utils_Type
::T_BOOLEAN
,
504 'title' => ts('Custom Field Is Required?'),
505 'description' => ts('Is a value required for this property.'),
507 'where' => 'civicrm_custom_field.is_required',
509 'table_name' => 'civicrm_custom_field',
510 'entity' => 'CustomField',
511 'bao' => 'CRM_Core_BAO_CustomField',
516 'name' => 'is_searchable',
517 'type' => CRM_Utils_Type
::T_BOOLEAN
,
518 'title' => ts('Allow Searching on Field?'),
519 'description' => ts('Is this property searchable.'),
521 'where' => 'civicrm_custom_field.is_searchable',
523 'table_name' => 'civicrm_custom_field',
524 'entity' => 'CustomField',
525 'bao' => 'CRM_Core_BAO_CustomField',
529 'is_search_range' => [
530 'name' => 'is_search_range',
531 'type' => CRM_Utils_Type
::T_BOOLEAN
,
532 'title' => ts('Search as a Range'),
533 'description' => ts('Is this property range searchable.'),
535 'where' => 'civicrm_custom_field.is_search_range',
537 'table_name' => 'civicrm_custom_field',
538 'entity' => 'CustomField',
539 'bao' => 'CRM_Core_BAO_CustomField',
545 'type' => CRM_Utils_Type
::T_INT
,
546 'title' => ts('Order'),
547 'description' => ts('Controls field display order within an extended property group.'),
549 'where' => 'civicrm_custom_field.weight',
551 'table_name' => 'civicrm_custom_field',
552 'entity' => 'CustomField',
553 'bao' => 'CRM_Core_BAO_CustomField',
558 'name' => 'help_pre',
559 'type' => CRM_Utils_Type
::T_TEXT
,
560 'title' => ts('Custom Field Pre Text'),
561 'description' => ts('Description and/or help text to display before this field.'),
562 'where' => 'civicrm_custom_field.help_pre',
563 'table_name' => 'civicrm_custom_field',
564 'entity' => 'CustomField',
565 'bao' => 'CRM_Core_BAO_CustomField',
570 'name' => 'help_post',
571 'type' => CRM_Utils_Type
::T_TEXT
,
572 'title' => ts('Custom Field Post Text'),
573 'description' => ts('Description and/or help text to display after this field.'),
574 'where' => 'civicrm_custom_field.help_post',
575 'table_name' => 'civicrm_custom_field',
576 'entity' => 'CustomField',
577 'bao' => 'CRM_Core_BAO_CustomField',
583 'type' => CRM_Utils_Type
::T_STRING
,
584 'title' => ts('Custom Field Formatting'),
585 'description' => ts('Optional format instructions for specific field types, like date types.'),
587 'size' => CRM_Utils_Type
::BIG
,
588 'where' => 'civicrm_custom_field.mask',
589 'table_name' => 'civicrm_custom_field',
590 'entity' => 'CustomField',
591 'bao' => 'CRM_Core_BAO_CustomField',
596 'name' => 'attributes',
597 'type' => CRM_Utils_Type
::T_STRING
,
598 'title' => ts('Custom Field Attributes'),
599 'description' => ts('Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes'),
601 'size' => CRM_Utils_Type
::HUGE
,
602 'where' => 'civicrm_custom_field.attributes',
603 'table_name' => 'civicrm_custom_field',
604 'entity' => 'CustomField',
605 'bao' => 'CRM_Core_BAO_CustomField',
610 'name' => 'javascript',
611 'type' => CRM_Utils_Type
::T_STRING
,
612 'title' => ts('Custom Field Javascript'),
613 'description' => ts('Optional scripting attributes for field.'),
615 'size' => CRM_Utils_Type
::HUGE
,
616 'where' => 'civicrm_custom_field.javascript',
617 'table_name' => 'civicrm_custom_field',
618 'entity' => 'CustomField',
619 'bao' => 'CRM_Core_BAO_CustomField',
624 'name' => 'is_active',
625 'type' => CRM_Utils_Type
::T_BOOLEAN
,
626 'title' => ts('Custom Field Is Active?'),
627 'description' => ts('Is this property active?'),
628 'where' => 'civicrm_custom_field.is_active',
630 'table_name' => 'civicrm_custom_field',
631 'entity' => 'CustomField',
632 'bao' => 'CRM_Core_BAO_CustomField',
638 'type' => CRM_Utils_Type
::T_BOOLEAN
,
639 'title' => ts('Field is Viewable'),
640 'description' => ts('Is this property set by PHP Code? A code field is viewable but not editable'),
642 'where' => 'civicrm_custom_field.is_view',
644 'table_name' => 'civicrm_custom_field',
645 'entity' => 'CustomField',
646 'bao' => 'CRM_Core_BAO_CustomField',
650 'options_per_line' => [
651 'name' => 'options_per_line',
652 'type' => CRM_Utils_Type
::T_INT
,
653 'title' => ts('Field Options Per Line'),
654 'description' => ts('number of options per line for checkbox and radio'),
655 'where' => 'civicrm_custom_field.options_per_line',
656 'table_name' => 'civicrm_custom_field',
657 'entity' => 'CustomField',
658 'bao' => 'CRM_Core_BAO_CustomField',
663 'name' => 'text_length',
664 'type' => CRM_Utils_Type
::T_INT
,
665 'title' => ts('Field Length'),
666 'description' => ts('field length if alphanumeric'),
667 'where' => 'civicrm_custom_field.text_length',
668 'table_name' => 'civicrm_custom_field',
669 'entity' => 'CustomField',
670 'bao' => 'CRM_Core_BAO_CustomField',
674 'start_date_years' => [
675 'name' => 'start_date_years',
676 'type' => CRM_Utils_Type
::T_INT
,
677 'title' => ts('Field Start Date'),
678 'description' => ts('Date may be up to start_date_years years prior to the current date.'),
679 'where' => 'civicrm_custom_field.start_date_years',
680 'table_name' => 'civicrm_custom_field',
681 'entity' => 'CustomField',
682 'bao' => 'CRM_Core_BAO_CustomField',
686 'end_date_years' => [
687 'name' => 'end_date_years',
688 'type' => CRM_Utils_Type
::T_INT
,
689 'title' => ts('Field End Date'),
690 'description' => ts('Date may be up to end_date_years years after the current date.'),
691 'where' => 'civicrm_custom_field.end_date_years',
692 'table_name' => 'civicrm_custom_field',
693 'entity' => 'CustomField',
694 'bao' => 'CRM_Core_BAO_CustomField',
699 'name' => 'date_format',
700 'type' => CRM_Utils_Type
::T_STRING
,
701 'title' => ts('Field Data Format'),
702 'description' => ts('date format for custom date'),
704 'size' => CRM_Utils_Type
::BIG
,
705 'where' => 'civicrm_custom_field.date_format',
706 'table_name' => 'civicrm_custom_field',
707 'entity' => 'CustomField',
708 'bao' => 'CRM_Core_BAO_CustomField',
710 'pseudoconstant' => [
711 'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats',
716 'name' => 'time_format',
717 'type' => CRM_Utils_Type
::T_INT
,
718 'title' => ts('Field Time Format'),
719 'description' => ts('time format for custom date'),
720 'where' => 'civicrm_custom_field.time_format',
721 'table_name' => 'civicrm_custom_field',
722 'entity' => 'CustomField',
723 'bao' => 'CRM_Core_BAO_CustomField',
725 'pseudoconstant' => [
726 'callback' => 'CRM_Core_SelectValues::getTimeFormats',
731 'name' => 'note_columns',
732 'type' => CRM_Utils_Type
::T_INT
,
733 'title' => ts('Field Note Columns'),
734 'description' => ts('Number of columns in Note Field'),
735 'where' => 'civicrm_custom_field.note_columns',
736 'table_name' => 'civicrm_custom_field',
737 'entity' => 'CustomField',
738 'bao' => 'CRM_Core_BAO_CustomField',
743 'name' => 'note_rows',
744 'type' => CRM_Utils_Type
::T_INT
,
745 'title' => ts('Field Note Rows'),
746 'description' => ts('Number of rows in Note Field'),
747 'where' => 'civicrm_custom_field.note_rows',
748 'table_name' => 'civicrm_custom_field',
749 'entity' => 'CustomField',
750 'bao' => 'CRM_Core_BAO_CustomField',
755 'name' => 'column_name',
756 'type' => CRM_Utils_Type
::T_STRING
,
757 'title' => ts('Field Column Name'),
758 'description' => ts('Name of the column that holds the values for this field.'),
760 'size' => CRM_Utils_Type
::HUGE
,
761 'where' => 'civicrm_custom_field.column_name',
762 'table_name' => 'civicrm_custom_field',
763 'entity' => 'CustomField',
764 'bao' => 'CRM_Core_BAO_CustomField',
768 'option_group_id' => [
769 'name' => 'option_group_id',
770 'type' => CRM_Utils_Type
::T_INT
,
771 'title' => ts('Field Option Group ID'),
772 'description' => ts('For elements with options, the option group id that is used'),
773 'where' => 'civicrm_custom_field.option_group_id',
774 'table_name' => 'civicrm_custom_field',
775 'entity' => 'CustomField',
776 'bao' => 'CRM_Core_BAO_CustomField',
778 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
780 'label' => ts("Field Option Group"),
782 'pseudoconstant' => [
783 'table' => 'civicrm_option_group',
785 'labelColumn' => 'title',
790 'name' => 'serialize',
791 'type' => CRM_Utils_Type
::T_INT
,
792 'title' => ts('Serialize'),
793 'description' => ts('Serialization method - a non-zero value indicates a multi-valued field.'),
795 'where' => 'civicrm_custom_field.serialize',
797 'table_name' => 'civicrm_custom_field',
798 'entity' => 'CustomField',
799 'bao' => 'CRM_Core_BAO_CustomField',
801 'pseudoconstant' => [
802 'callback' => 'CRM_Core_SelectValues::fieldSerialization',
808 'type' => CRM_Utils_Type
::T_STRING
,
809 'title' => ts('Field Filter'),
810 'description' => ts('Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.'),
812 'size' => CRM_Utils_Type
::HUGE
,
813 'where' => 'civicrm_custom_field.filter',
814 'table_name' => 'civicrm_custom_field',
815 'entity' => 'CustomField',
816 'bao' => 'CRM_Core_BAO_CustomField',
821 'name' => 'in_selector',
822 'type' => CRM_Utils_Type
::T_BOOLEAN
,
823 'title' => ts('Field Display'),
824 'description' => ts('Should the multi-record custom field values be displayed in tab table listing'),
826 'where' => 'civicrm_custom_field.in_selector',
828 'table_name' => 'civicrm_custom_field',
829 'entity' => 'CustomField',
830 'bao' => 'CRM_Core_BAO_CustomField',
835 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
837 return Civi
::$statics[__CLASS__
]['fields'];
841 * Return a mapping from field-name to the corresponding key (as used in fields()).
844 * Array(string $name => string $uniqueName).
846 public static function &fieldKeys() {
847 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
848 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
850 return Civi
::$statics[__CLASS__
]['fieldKeys'];
854 * Returns the names of this table
858 public static function getTableName() {
859 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
863 * Returns if this table needs to be logged
867 public function getLog() {
872 * Returns the list of fields that can be imported
874 * @param bool $prefix
878 public static function &import($prefix = FALSE) {
879 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'custom_field', $prefix, []);
884 * Returns the list of fields that can be exported
886 * @param bool $prefix
890 public static function &export($prefix = FALSE) {
891 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'custom_field', $prefix, []);
896 * Returns the list of indices
898 * @param bool $localize
902 public static function indices($localize = TRUE) {
904 'UI_label_custom_group_id' => [
905 'name' => 'UI_label_custom_group_id',
908 1 => 'custom_group_id',
910 'localizable' => TRUE,
912 'sig' => 'civicrm_custom_field::1::label::custom_group_id',
914 'UI_name_custom_group_id' => [
915 'name' => 'UI_name_custom_group_id',
918 1 => 'custom_group_id',
920 'localizable' => FALSE,
922 'sig' => 'civicrm_custom_field::1::name::custom_group_id',
925 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;