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:c093cac865bba7796c2c7deda6579f40)
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/field?action=preview&reset=1&id=[id]&gid=[custom_group_id]',
49 'delete' => 'civicrm/admin/custom/group/field?action=delete&reset=1&id=[id]&gid=[custom_group_id]',
50 'move' => 'civicrm/admin/custom/group/field/move?reset=1&fid=[id]',
54 * Unique Custom Field ID
61 * FK to civicrm_custom_group.
65 public $custom_group_id;
68 * Variable name/programmatic handle for this field.
75 * Text for form field label (also friendly name for administering this custom property).
82 * Controls location of data storage in extended_data table.
89 * HTML types plus several built-in extended types.
96 * Use form_options.is_default for field_types which use options.
100 public $default_value;
103 * Is a value required for this property.
110 * Is this property searchable.
114 public $is_searchable;
117 * Is this property range searchable.
121 public $is_search_range;
124 * Controls field display order within an extended property group.
131 * Description and/or help text to display before this field.
138 * Description and/or help text to display after this field.
145 * Optional format instructions for specific field types, like date types.
152 * Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes
159 * Optional scripting attributes for field.
166 * Is this property active?
173 * Is this property set by PHP Code? A code field is viewable but not editable
180 * number of options per line for checkbox and radio
184 public $options_per_line;
187 * field length if alphanumeric
194 * Date may be up to start_date_years years prior to the current date.
198 public $start_date_years;
201 * Date may be up to end_date_years years after the current date.
205 public $end_date_years;
208 * date format for custom date
215 * time format for custom date
222 * Number of columns in Note Field
226 public $note_columns;
229 * Number of rows in Note Field
236 * Name of the column that holds the values for this field.
243 * For elements with options, the option group id that is used
247 public $option_group_id;
250 * Serialization method - a non-zero value indicates a multi-valued field.
257 * Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.
264 * Should the multi-record custom field values be displayed in tab table listing
273 public function __construct() {
274 $this->__table
= 'civicrm_custom_field';
275 parent
::__construct();
279 * Returns localized title of this entity.
281 * @param bool $plural
282 * Whether to return the plural version of the title.
284 public static function getEntityTitle($plural = FALSE) {
285 return $plural ?
ts('Custom Fields') : ts('Custom Field');
289 * Returns foreign keys and entity references.
292 * [CRM_Core_Reference_Interface]
294 public static function getReferenceColumns() {
295 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
296 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
297 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'custom_group_id', 'civicrm_custom_group', 'id');
298 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'option_group_id', 'civicrm_option_group', 'id');
299 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
301 return Civi
::$statics[__CLASS__
]['links'];
305 * Returns all the column names of this table
309 public static function &fields() {
310 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
311 Civi
::$statics[__CLASS__
]['fields'] = [
314 'type' => CRM_Utils_Type
::T_INT
,
315 'title' => ts('Custom Field ID'),
316 'description' => ts('Unique Custom Field ID'),
318 'where' => 'civicrm_custom_field.id',
319 'table_name' => 'civicrm_custom_field',
320 'entity' => 'CustomField',
321 'bao' => 'CRM_Core_BAO_CustomField',
329 'custom_group_id' => [
330 'name' => 'custom_group_id',
331 'type' => CRM_Utils_Type
::T_INT
,
332 'title' => ts('Custom Group ID'),
333 'description' => ts('FK to civicrm_custom_group.'),
335 'where' => 'civicrm_custom_field.custom_group_id',
336 'table_name' => 'civicrm_custom_field',
337 'entity' => 'CustomField',
338 'bao' => 'CRM_Core_BAO_CustomField',
340 'FKClassName' => 'CRM_Core_DAO_CustomGroup',
343 'label' => ts("Custom Group"),
345 'pseudoconstant' => [
346 'table' => 'civicrm_custom_group',
348 'labelColumn' => 'title',
354 'type' => CRM_Utils_Type
::T_STRING
,
355 'title' => ts('Custom Field Name'),
356 'description' => ts('Variable name/programmatic handle for this field.'),
358 'size' => CRM_Utils_Type
::BIG
,
359 'where' => 'civicrm_custom_field.name',
360 'table_name' => 'civicrm_custom_field',
361 'entity' => 'CustomField',
362 'bao' => 'CRM_Core_BAO_CustomField',
368 'type' => CRM_Utils_Type
::T_STRING
,
369 'title' => ts('Custom Field Label'),
370 'description' => ts('Text for form field label (also friendly name for administering this custom property).'),
373 'size' => CRM_Utils_Type
::HUGE
,
374 'where' => 'civicrm_custom_field.label',
375 'table_name' => 'civicrm_custom_field',
376 'entity' => 'CustomField',
377 'bao' => 'CRM_Core_BAO_CustomField',
382 'name' => 'data_type',
383 'type' => CRM_Utils_Type
::T_STRING
,
384 'title' => ts('Data Type'),
385 'description' => ts('Controls location of data storage in extended_data table.'),
388 'size' => CRM_Utils_Type
::TWELVE
,
389 'where' => 'civicrm_custom_field.data_type',
390 'table_name' => 'civicrm_custom_field',
391 'entity' => 'CustomField',
392 'bao' => 'CRM_Core_BAO_CustomField',
396 'label' => ts("Data Type"),
398 'pseudoconstant' => [
399 'callback' => 'CRM_Core_BAO_CustomField::dataType',
404 'name' => 'html_type',
405 'type' => CRM_Utils_Type
::T_STRING
,
406 'title' => ts('HTML Type'),
407 'description' => ts('HTML types plus several built-in extended types.'),
410 'size' => CRM_Utils_Type
::MEDIUM
,
411 'where' => 'civicrm_custom_field.html_type',
412 'table_name' => 'civicrm_custom_field',
413 'entity' => 'CustomField',
414 'bao' => 'CRM_Core_BAO_CustomField',
418 'label' => ts("Field Input Type"),
420 'pseudoconstant' => [
421 'callback' => 'CRM_Core_SelectValues::customHtmlType',
426 'name' => 'default_value',
427 'type' => CRM_Utils_Type
::T_STRING
,
428 'title' => ts('Custom Field Default'),
429 'description' => ts('Use form_options.is_default for field_types which use options.'),
431 'size' => CRM_Utils_Type
::HUGE
,
432 'where' => 'civicrm_custom_field.default_value',
433 'table_name' => 'civicrm_custom_field',
434 'entity' => 'CustomField',
435 'bao' => 'CRM_Core_BAO_CustomField',
440 'name' => 'is_required',
441 'type' => CRM_Utils_Type
::T_BOOLEAN
,
442 'title' => ts('Custom Field Is Required?'),
443 'description' => ts('Is a value required for this property.'),
444 'where' => 'civicrm_custom_field.is_required',
446 'table_name' => 'civicrm_custom_field',
447 'entity' => 'CustomField',
448 'bao' => 'CRM_Core_BAO_CustomField',
453 'name' => 'is_searchable',
454 'type' => CRM_Utils_Type
::T_BOOLEAN
,
455 'title' => ts('Allow Searching on Field?'),
456 'description' => ts('Is this property searchable.'),
457 'where' => 'civicrm_custom_field.is_searchable',
459 'table_name' => 'civicrm_custom_field',
460 'entity' => 'CustomField',
461 'bao' => 'CRM_Core_BAO_CustomField',
465 'is_search_range' => [
466 'name' => 'is_search_range',
467 'type' => CRM_Utils_Type
::T_BOOLEAN
,
468 'title' => ts('Search as a Range'),
469 'description' => ts('Is this property range searchable.'),
470 'where' => 'civicrm_custom_field.is_search_range',
472 'table_name' => 'civicrm_custom_field',
473 'entity' => 'CustomField',
474 'bao' => 'CRM_Core_BAO_CustomField',
480 'type' => CRM_Utils_Type
::T_INT
,
481 'title' => ts('Order'),
482 'description' => ts('Controls field display order within an extended property group.'),
484 'where' => 'civicrm_custom_field.weight',
486 'table_name' => 'civicrm_custom_field',
487 'entity' => 'CustomField',
488 'bao' => 'CRM_Core_BAO_CustomField',
493 'name' => 'help_pre',
494 'type' => CRM_Utils_Type
::T_TEXT
,
495 'title' => ts('Custom Field Pre Text'),
496 'description' => ts('Description and/or help text to display before this field.'),
497 'where' => 'civicrm_custom_field.help_pre',
498 'table_name' => 'civicrm_custom_field',
499 'entity' => 'CustomField',
500 'bao' => 'CRM_Core_BAO_CustomField',
505 'name' => 'help_post',
506 'type' => CRM_Utils_Type
::T_TEXT
,
507 'title' => ts('Custom Field Post Text'),
508 'description' => ts('Description and/or help text to display after this field.'),
509 'where' => 'civicrm_custom_field.help_post',
510 'table_name' => 'civicrm_custom_field',
511 'entity' => 'CustomField',
512 'bao' => 'CRM_Core_BAO_CustomField',
518 'type' => CRM_Utils_Type
::T_STRING
,
519 'title' => ts('Custom Field Formatting'),
520 'description' => ts('Optional format instructions for specific field types, like date types.'),
522 'size' => CRM_Utils_Type
::BIG
,
523 'where' => 'civicrm_custom_field.mask',
524 'table_name' => 'civicrm_custom_field',
525 'entity' => 'CustomField',
526 'bao' => 'CRM_Core_BAO_CustomField',
531 'name' => 'attributes',
532 'type' => CRM_Utils_Type
::T_STRING
,
533 'title' => ts('Custom Field Attributes'),
534 'description' => ts('Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes'),
536 'size' => CRM_Utils_Type
::HUGE
,
537 'where' => 'civicrm_custom_field.attributes',
538 'table_name' => 'civicrm_custom_field',
539 'entity' => 'CustomField',
540 'bao' => 'CRM_Core_BAO_CustomField',
545 'name' => 'javascript',
546 'type' => CRM_Utils_Type
::T_STRING
,
547 'title' => ts('Custom Field Javascript'),
548 'description' => ts('Optional scripting attributes for field.'),
550 'size' => CRM_Utils_Type
::HUGE
,
551 'where' => 'civicrm_custom_field.javascript',
552 'table_name' => 'civicrm_custom_field',
553 'entity' => 'CustomField',
554 'bao' => 'CRM_Core_BAO_CustomField',
559 'name' => 'is_active',
560 'type' => CRM_Utils_Type
::T_BOOLEAN
,
561 'title' => ts('Custom Field Is Active?'),
562 'description' => ts('Is this property active?'),
563 'where' => 'civicrm_custom_field.is_active',
565 'table_name' => 'civicrm_custom_field',
566 'entity' => 'CustomField',
567 'bao' => 'CRM_Core_BAO_CustomField',
573 'type' => CRM_Utils_Type
::T_BOOLEAN
,
574 'title' => ts('Field is Viewable'),
575 'description' => ts('Is this property set by PHP Code? A code field is viewable but not editable'),
576 'where' => 'civicrm_custom_field.is_view',
578 'table_name' => 'civicrm_custom_field',
579 'entity' => 'CustomField',
580 'bao' => 'CRM_Core_BAO_CustomField',
584 'options_per_line' => [
585 'name' => 'options_per_line',
586 'type' => CRM_Utils_Type
::T_INT
,
587 'title' => ts('Field Options Per Line'),
588 'description' => ts('number of options per line for checkbox and radio'),
589 'where' => 'civicrm_custom_field.options_per_line',
590 'table_name' => 'civicrm_custom_field',
591 'entity' => 'CustomField',
592 'bao' => 'CRM_Core_BAO_CustomField',
597 'name' => 'text_length',
598 'type' => CRM_Utils_Type
::T_INT
,
599 'title' => ts('Field Length'),
600 'description' => ts('field length if alphanumeric'),
601 'where' => 'civicrm_custom_field.text_length',
602 'table_name' => 'civicrm_custom_field',
603 'entity' => 'CustomField',
604 'bao' => 'CRM_Core_BAO_CustomField',
608 'start_date_years' => [
609 'name' => 'start_date_years',
610 'type' => CRM_Utils_Type
::T_INT
,
611 'title' => ts('Field Start Date'),
612 'description' => ts('Date may be up to start_date_years years prior to the current date.'),
613 'where' => 'civicrm_custom_field.start_date_years',
614 'table_name' => 'civicrm_custom_field',
615 'entity' => 'CustomField',
616 'bao' => 'CRM_Core_BAO_CustomField',
620 'end_date_years' => [
621 'name' => 'end_date_years',
622 'type' => CRM_Utils_Type
::T_INT
,
623 'title' => ts('Field End Date'),
624 'description' => ts('Date may be up to end_date_years years after the current date.'),
625 'where' => 'civicrm_custom_field.end_date_years',
626 'table_name' => 'civicrm_custom_field',
627 'entity' => 'CustomField',
628 'bao' => 'CRM_Core_BAO_CustomField',
633 'name' => 'date_format',
634 'type' => CRM_Utils_Type
::T_STRING
,
635 'title' => ts('Field Data Format'),
636 'description' => ts('date format for custom date'),
638 'size' => CRM_Utils_Type
::BIG
,
639 'where' => 'civicrm_custom_field.date_format',
640 'table_name' => 'civicrm_custom_field',
641 'entity' => 'CustomField',
642 'bao' => 'CRM_Core_BAO_CustomField',
644 'pseudoconstant' => [
645 'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats',
650 'name' => 'time_format',
651 'type' => CRM_Utils_Type
::T_INT
,
652 'title' => ts('Field Time Format'),
653 'description' => ts('time format for custom date'),
654 'where' => 'civicrm_custom_field.time_format',
655 'table_name' => 'civicrm_custom_field',
656 'entity' => 'CustomField',
657 'bao' => 'CRM_Core_BAO_CustomField',
659 'pseudoconstant' => [
660 'callback' => 'CRM_Core_SelectValues::getTimeFormats',
665 'name' => 'note_columns',
666 'type' => CRM_Utils_Type
::T_INT
,
667 'title' => ts('Field Note Columns'),
668 'description' => ts('Number of columns in Note Field'),
669 'where' => 'civicrm_custom_field.note_columns',
670 'table_name' => 'civicrm_custom_field',
671 'entity' => 'CustomField',
672 'bao' => 'CRM_Core_BAO_CustomField',
677 'name' => 'note_rows',
678 'type' => CRM_Utils_Type
::T_INT
,
679 'title' => ts('Field Note Rows'),
680 'description' => ts('Number of rows in Note Field'),
681 'where' => 'civicrm_custom_field.note_rows',
682 'table_name' => 'civicrm_custom_field',
683 'entity' => 'CustomField',
684 'bao' => 'CRM_Core_BAO_CustomField',
689 'name' => 'column_name',
690 'type' => CRM_Utils_Type
::T_STRING
,
691 'title' => ts('Field Column Name'),
692 'description' => ts('Name of the column that holds the values for this field.'),
694 'size' => CRM_Utils_Type
::HUGE
,
695 'where' => 'civicrm_custom_field.column_name',
696 'table_name' => 'civicrm_custom_field',
697 'entity' => 'CustomField',
698 'bao' => 'CRM_Core_BAO_CustomField',
702 'option_group_id' => [
703 'name' => 'option_group_id',
704 'type' => CRM_Utils_Type
::T_INT
,
705 'title' => ts('Field Option Group ID'),
706 'description' => ts('For elements with options, the option group id that is used'),
707 'where' => 'civicrm_custom_field.option_group_id',
708 'table_name' => 'civicrm_custom_field',
709 'entity' => 'CustomField',
710 'bao' => 'CRM_Core_BAO_CustomField',
712 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
714 'label' => ts("Field Option Group"),
716 'pseudoconstant' => [
717 'table' => 'civicrm_option_group',
719 'labelColumn' => 'title',
724 'name' => 'serialize',
725 'type' => CRM_Utils_Type
::T_INT
,
726 'title' => ts('Serialize'),
727 'description' => ts('Serialization method - a non-zero value indicates a multi-valued field.'),
729 'where' => 'civicrm_custom_field.serialize',
731 'table_name' => 'civicrm_custom_field',
732 'entity' => 'CustomField',
733 'bao' => 'CRM_Core_BAO_CustomField',
735 'pseudoconstant' => [
736 'callback' => 'CRM_Core_SelectValues::fieldSerialization',
742 'type' => CRM_Utils_Type
::T_STRING
,
743 'title' => ts('Field Filter'),
744 'description' => ts('Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.'),
746 'size' => CRM_Utils_Type
::HUGE
,
747 'where' => 'civicrm_custom_field.filter',
748 'table_name' => 'civicrm_custom_field',
749 'entity' => 'CustomField',
750 'bao' => 'CRM_Core_BAO_CustomField',
755 'name' => 'in_selector',
756 'type' => CRM_Utils_Type
::T_BOOLEAN
,
757 'title' => ts('Field Display'),
758 'description' => ts('Should the multi-record custom field values be displayed in tab table listing'),
759 'where' => 'civicrm_custom_field.in_selector',
761 'table_name' => 'civicrm_custom_field',
762 'entity' => 'CustomField',
763 'bao' => 'CRM_Core_BAO_CustomField',
768 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
770 return Civi
::$statics[__CLASS__
]['fields'];
774 * Return a mapping from field-name to the corresponding key (as used in fields()).
777 * Array(string $name => string $uniqueName).
779 public static function &fieldKeys() {
780 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
781 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
783 return Civi
::$statics[__CLASS__
]['fieldKeys'];
787 * Returns the names of this table
791 public static function getTableName() {
792 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
796 * Returns if this table needs to be logged
800 public function getLog() {
805 * Returns the list of fields that can be imported
807 * @param bool $prefix
811 public static function &import($prefix = FALSE) {
812 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'custom_field', $prefix, []);
817 * Returns the list of fields that can be exported
819 * @param bool $prefix
823 public static function &export($prefix = FALSE) {
824 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'custom_field', $prefix, []);
829 * Returns the list of indices
831 * @param bool $localize
835 public static function indices($localize = TRUE) {
837 'UI_label_custom_group_id' => [
838 'name' => 'UI_label_custom_group_id',
841 1 => 'custom_group_id',
843 'localizable' => TRUE,
845 'sig' => 'civicrm_custom_field::1::label::custom_group_id',
847 'UI_name_custom_group_id' => [
848 'name' => 'UI_name_custom_group_id',
851 1 => 'custom_group_id',
853 'localizable' => FALSE,
855 'sig' => 'civicrm_custom_field::1::name::custom_group_id',
858 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;