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:6653fe86552a321a498736c14cabc41d)
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.
119 * @var bool|string|null
120 * (SQL type: tinyint)
121 * Note that values will be retrieved from the database as a string.
126 * Is this property searchable.
128 * @var bool|string|null
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.
137 * @var bool|string|null
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
209 * @var bool|string|null
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
326 * @var bool|string|null
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.'),
506 'where' => 'civicrm_custom_field.is_required',
508 'table_name' => 'civicrm_custom_field',
509 'entity' => 'CustomField',
510 'bao' => 'CRM_Core_BAO_CustomField',
515 'name' => 'is_searchable',
516 'type' => CRM_Utils_Type
::T_BOOLEAN
,
517 'title' => ts('Allow Searching on Field?'),
518 'description' => ts('Is this property searchable.'),
519 'where' => 'civicrm_custom_field.is_searchable',
521 'table_name' => 'civicrm_custom_field',
522 'entity' => 'CustomField',
523 'bao' => 'CRM_Core_BAO_CustomField',
527 'is_search_range' => [
528 'name' => 'is_search_range',
529 'type' => CRM_Utils_Type
::T_BOOLEAN
,
530 'title' => ts('Search as a Range'),
531 'description' => ts('Is this property range searchable.'),
532 'where' => 'civicrm_custom_field.is_search_range',
534 'table_name' => 'civicrm_custom_field',
535 'entity' => 'CustomField',
536 'bao' => 'CRM_Core_BAO_CustomField',
542 'type' => CRM_Utils_Type
::T_INT
,
543 'title' => ts('Order'),
544 'description' => ts('Controls field display order within an extended property group.'),
546 'where' => 'civicrm_custom_field.weight',
548 'table_name' => 'civicrm_custom_field',
549 'entity' => 'CustomField',
550 'bao' => 'CRM_Core_BAO_CustomField',
555 'name' => 'help_pre',
556 'type' => CRM_Utils_Type
::T_TEXT
,
557 'title' => ts('Custom Field Pre Text'),
558 'description' => ts('Description and/or help text to display before this field.'),
559 'where' => 'civicrm_custom_field.help_pre',
560 'table_name' => 'civicrm_custom_field',
561 'entity' => 'CustomField',
562 'bao' => 'CRM_Core_BAO_CustomField',
567 'name' => 'help_post',
568 'type' => CRM_Utils_Type
::T_TEXT
,
569 'title' => ts('Custom Field Post Text'),
570 'description' => ts('Description and/or help text to display after this field.'),
571 'where' => 'civicrm_custom_field.help_post',
572 'table_name' => 'civicrm_custom_field',
573 'entity' => 'CustomField',
574 'bao' => 'CRM_Core_BAO_CustomField',
580 'type' => CRM_Utils_Type
::T_STRING
,
581 'title' => ts('Custom Field Formatting'),
582 'description' => ts('Optional format instructions for specific field types, like date types.'),
584 'size' => CRM_Utils_Type
::BIG
,
585 'where' => 'civicrm_custom_field.mask',
586 'table_name' => 'civicrm_custom_field',
587 'entity' => 'CustomField',
588 'bao' => 'CRM_Core_BAO_CustomField',
593 'name' => 'attributes',
594 'type' => CRM_Utils_Type
::T_STRING
,
595 'title' => ts('Custom Field Attributes'),
596 'description' => ts('Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes'),
598 'size' => CRM_Utils_Type
::HUGE
,
599 'where' => 'civicrm_custom_field.attributes',
600 'table_name' => 'civicrm_custom_field',
601 'entity' => 'CustomField',
602 'bao' => 'CRM_Core_BAO_CustomField',
607 'name' => 'javascript',
608 'type' => CRM_Utils_Type
::T_STRING
,
609 'title' => ts('Custom Field Javascript'),
610 'description' => ts('Optional scripting attributes for field.'),
612 'size' => CRM_Utils_Type
::HUGE
,
613 'where' => 'civicrm_custom_field.javascript',
614 'table_name' => 'civicrm_custom_field',
615 'entity' => 'CustomField',
616 'bao' => 'CRM_Core_BAO_CustomField',
621 'name' => 'is_active',
622 'type' => CRM_Utils_Type
::T_BOOLEAN
,
623 'title' => ts('Custom Field Is Active?'),
624 'description' => ts('Is this property active?'),
625 'where' => 'civicrm_custom_field.is_active',
627 'table_name' => 'civicrm_custom_field',
628 'entity' => 'CustomField',
629 'bao' => 'CRM_Core_BAO_CustomField',
635 'type' => CRM_Utils_Type
::T_BOOLEAN
,
636 'title' => ts('Field is Viewable'),
637 'description' => ts('Is this property set by PHP Code? A code field is viewable but not editable'),
638 'where' => 'civicrm_custom_field.is_view',
640 'table_name' => 'civicrm_custom_field',
641 'entity' => 'CustomField',
642 'bao' => 'CRM_Core_BAO_CustomField',
646 'options_per_line' => [
647 'name' => 'options_per_line',
648 'type' => CRM_Utils_Type
::T_INT
,
649 'title' => ts('Field Options Per Line'),
650 'description' => ts('number of options per line for checkbox and radio'),
651 'where' => 'civicrm_custom_field.options_per_line',
652 'table_name' => 'civicrm_custom_field',
653 'entity' => 'CustomField',
654 'bao' => 'CRM_Core_BAO_CustomField',
659 'name' => 'text_length',
660 'type' => CRM_Utils_Type
::T_INT
,
661 'title' => ts('Field Length'),
662 'description' => ts('field length if alphanumeric'),
663 'where' => 'civicrm_custom_field.text_length',
664 'table_name' => 'civicrm_custom_field',
665 'entity' => 'CustomField',
666 'bao' => 'CRM_Core_BAO_CustomField',
670 'start_date_years' => [
671 'name' => 'start_date_years',
672 'type' => CRM_Utils_Type
::T_INT
,
673 'title' => ts('Field Start Date'),
674 'description' => ts('Date may be up to start_date_years years prior to the current date.'),
675 'where' => 'civicrm_custom_field.start_date_years',
676 'table_name' => 'civicrm_custom_field',
677 'entity' => 'CustomField',
678 'bao' => 'CRM_Core_BAO_CustomField',
682 'end_date_years' => [
683 'name' => 'end_date_years',
684 'type' => CRM_Utils_Type
::T_INT
,
685 'title' => ts('Field End Date'),
686 'description' => ts('Date may be up to end_date_years years after the current date.'),
687 'where' => 'civicrm_custom_field.end_date_years',
688 'table_name' => 'civicrm_custom_field',
689 'entity' => 'CustomField',
690 'bao' => 'CRM_Core_BAO_CustomField',
695 'name' => 'date_format',
696 'type' => CRM_Utils_Type
::T_STRING
,
697 'title' => ts('Field Data Format'),
698 'description' => ts('date format for custom date'),
700 'size' => CRM_Utils_Type
::BIG
,
701 'where' => 'civicrm_custom_field.date_format',
702 'table_name' => 'civicrm_custom_field',
703 'entity' => 'CustomField',
704 'bao' => 'CRM_Core_BAO_CustomField',
706 'pseudoconstant' => [
707 'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats',
712 'name' => 'time_format',
713 'type' => CRM_Utils_Type
::T_INT
,
714 'title' => ts('Field Time Format'),
715 'description' => ts('time format for custom date'),
716 'where' => 'civicrm_custom_field.time_format',
717 'table_name' => 'civicrm_custom_field',
718 'entity' => 'CustomField',
719 'bao' => 'CRM_Core_BAO_CustomField',
721 'pseudoconstant' => [
722 'callback' => 'CRM_Core_SelectValues::getTimeFormats',
727 'name' => 'note_columns',
728 'type' => CRM_Utils_Type
::T_INT
,
729 'title' => ts('Field Note Columns'),
730 'description' => ts('Number of columns in Note Field'),
731 'where' => 'civicrm_custom_field.note_columns',
732 'table_name' => 'civicrm_custom_field',
733 'entity' => 'CustomField',
734 'bao' => 'CRM_Core_BAO_CustomField',
739 'name' => 'note_rows',
740 'type' => CRM_Utils_Type
::T_INT
,
741 'title' => ts('Field Note Rows'),
742 'description' => ts('Number of rows in Note Field'),
743 'where' => 'civicrm_custom_field.note_rows',
744 'table_name' => 'civicrm_custom_field',
745 'entity' => 'CustomField',
746 'bao' => 'CRM_Core_BAO_CustomField',
751 'name' => 'column_name',
752 'type' => CRM_Utils_Type
::T_STRING
,
753 'title' => ts('Field Column Name'),
754 'description' => ts('Name of the column that holds the values for this field.'),
756 'size' => CRM_Utils_Type
::HUGE
,
757 'where' => 'civicrm_custom_field.column_name',
758 'table_name' => 'civicrm_custom_field',
759 'entity' => 'CustomField',
760 'bao' => 'CRM_Core_BAO_CustomField',
764 'option_group_id' => [
765 'name' => 'option_group_id',
766 'type' => CRM_Utils_Type
::T_INT
,
767 'title' => ts('Field Option Group ID'),
768 'description' => ts('For elements with options, the option group id that is used'),
769 'where' => 'civicrm_custom_field.option_group_id',
770 'table_name' => 'civicrm_custom_field',
771 'entity' => 'CustomField',
772 'bao' => 'CRM_Core_BAO_CustomField',
774 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
776 'label' => ts("Field Option Group"),
778 'pseudoconstant' => [
779 'table' => 'civicrm_option_group',
781 'labelColumn' => 'title',
786 'name' => 'serialize',
787 'type' => CRM_Utils_Type
::T_INT
,
788 'title' => ts('Serialize'),
789 'description' => ts('Serialization method - a non-zero value indicates a multi-valued field.'),
791 'where' => 'civicrm_custom_field.serialize',
793 'table_name' => 'civicrm_custom_field',
794 'entity' => 'CustomField',
795 'bao' => 'CRM_Core_BAO_CustomField',
797 'pseudoconstant' => [
798 'callback' => 'CRM_Core_SelectValues::fieldSerialization',
804 'type' => CRM_Utils_Type
::T_STRING
,
805 'title' => ts('Field Filter'),
806 'description' => ts('Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.'),
808 'size' => CRM_Utils_Type
::HUGE
,
809 'where' => 'civicrm_custom_field.filter',
810 'table_name' => 'civicrm_custom_field',
811 'entity' => 'CustomField',
812 'bao' => 'CRM_Core_BAO_CustomField',
817 'name' => 'in_selector',
818 'type' => CRM_Utils_Type
::T_BOOLEAN
,
819 'title' => ts('Field Display'),
820 'description' => ts('Should the multi-record custom field values be displayed in tab table listing'),
821 'where' => 'civicrm_custom_field.in_selector',
823 'table_name' => 'civicrm_custom_field',
824 'entity' => 'CustomField',
825 'bao' => 'CRM_Core_BAO_CustomField',
830 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
832 return Civi
::$statics[__CLASS__
]['fields'];
836 * Return a mapping from field-name to the corresponding key (as used in fields()).
839 * Array(string $name => string $uniqueName).
841 public static function &fieldKeys() {
842 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
843 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
845 return Civi
::$statics[__CLASS__
]['fieldKeys'];
849 * Returns the names of this table
853 public static function getTableName() {
854 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
858 * Returns if this table needs to be logged
862 public function getLog() {
867 * Returns the list of fields that can be imported
869 * @param bool $prefix
873 public static function &import($prefix = FALSE) {
874 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'custom_field', $prefix, []);
879 * Returns the list of fields that can be exported
881 * @param bool $prefix
885 public static function &export($prefix = FALSE) {
886 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'custom_field', $prefix, []);
891 * Returns the list of indices
893 * @param bool $localize
897 public static function indices($localize = TRUE) {
899 'UI_label_custom_group_id' => [
900 'name' => 'UI_label_custom_group_id',
903 1 => 'custom_group_id',
905 'localizable' => TRUE,
907 'sig' => 'civicrm_custom_field::1::label::custom_group_id',
909 'UI_name_custom_group_id' => [
910 'name' => 'UI_name_custom_group_id',
913 1 => 'custom_group_id',
915 'localizable' => FALSE,
917 'sig' => 'civicrm_custom_field::1::name::custom_group_id',
920 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;