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:30f1deaf5c81a0f9cffb0219507d2e4f)
13 * Database access object for the CustomField entity.
15 class CRM_Core_DAO_CustomField
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_custom_field';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
32 * Unique Custom Field ID
39 * FK to civicrm_custom_group.
43 public $custom_group_id;
46 * Variable name/programmatic handle for this group.
53 * Text for form field label (also friendly name for administering this custom property).
60 * Controls location of data storage in extended_data table.
67 * HTML types plus several built-in extended types.
74 * Use form_options.is_default for field_types which use options.
78 public $default_value;
81 * Is a value required for this property.
88 * Is this property searchable.
92 public $is_searchable;
95 * Is this property range searchable.
99 public $is_search_range;
102 * Controls field display order within an extended property group.
109 * Description and/or help text to display before this field.
116 * Description and/or help text to display after this field.
123 * Optional format instructions for specific field types, like date types.
130 * Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes
137 * Optional scripting attributes for field.
144 * Is this property active?
151 * Is this property set by PHP Code? A code field is viewable but not editable
158 * number of options per line for checkbox and radio
162 public $options_per_line;
165 * field length if alphanumeric
172 * Date may be up to start_date_years years prior to the current date.
176 public $start_date_years;
179 * Date may be up to end_date_years years after the current date.
183 public $end_date_years;
186 * date format for custom date
193 * time format for custom date
200 * Number of columns in Note Field
204 public $note_columns;
207 * Number of rows in Note Field
214 * Name of the column that holds the values for this field.
221 * For elements with options, the option group id that is used
225 public $option_group_id;
228 * Serialization method - a non-null value indicates a multi-valued field.
235 * Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.
242 * Should the multi-record custom field values be displayed in tab table listing
251 public function __construct() {
252 $this->__table
= 'civicrm_custom_field';
253 parent
::__construct();
257 * Returns localized title of this entity.
259 public static function getEntityTitle() {
260 return ts('Custom Fields');
264 * Returns foreign keys and entity references.
267 * [CRM_Core_Reference_Interface]
269 public static function getReferenceColumns() {
270 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
271 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
272 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'custom_group_id', 'civicrm_custom_group', 'id');
273 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'option_group_id', 'civicrm_option_group', 'id');
274 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
276 return Civi
::$statics[__CLASS__
]['links'];
280 * Returns all the column names of this table
284 public static function &fields() {
285 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
286 Civi
::$statics[__CLASS__
]['fields'] = [
289 'type' => CRM_Utils_Type
::T_INT
,
290 'title' => ts('Custom Field ID'),
291 'description' => ts('Unique Custom Field ID'),
293 'where' => 'civicrm_custom_field.id',
294 'table_name' => 'civicrm_custom_field',
295 'entity' => 'CustomField',
296 'bao' => 'CRM_Core_BAO_CustomField',
300 'custom_group_id' => [
301 'name' => 'custom_group_id',
302 'type' => CRM_Utils_Type
::T_INT
,
303 'title' => ts('Custom Group'),
304 'description' => ts('FK to civicrm_custom_group.'),
306 'where' => 'civicrm_custom_field.custom_group_id',
307 'table_name' => 'civicrm_custom_field',
308 'entity' => 'CustomField',
309 'bao' => 'CRM_Core_BAO_CustomField',
311 'FKClassName' => 'CRM_Core_DAO_CustomGroup',
315 'pseudoconstant' => [
316 'table' => 'civicrm_custom_group',
318 'labelColumn' => 'title',
324 'type' => CRM_Utils_Type
::T_STRING
,
325 'title' => ts('Custom Field Name'),
326 'description' => ts('Variable name/programmatic handle for this group.'),
328 'size' => CRM_Utils_Type
::BIG
,
329 'where' => 'civicrm_custom_field.name',
330 'table_name' => 'civicrm_custom_field',
331 'entity' => 'CustomField',
332 'bao' => 'CRM_Core_BAO_CustomField',
338 'type' => CRM_Utils_Type
::T_STRING
,
339 'title' => ts('Custom Field Label'),
340 'description' => ts('Text for form field label (also friendly name for administering this custom property).'),
343 'size' => CRM_Utils_Type
::HUGE
,
344 'where' => 'civicrm_custom_field.label',
345 'table_name' => 'civicrm_custom_field',
346 'entity' => 'CustomField',
347 'bao' => 'CRM_Core_BAO_CustomField',
352 'name' => 'data_type',
353 'type' => CRM_Utils_Type
::T_STRING
,
354 'title' => ts('Custom Field Data Type'),
355 'description' => ts('Controls location of data storage in extended_data table.'),
358 'size' => CRM_Utils_Type
::TWELVE
,
359 'where' => 'civicrm_custom_field.data_type',
360 'table_name' => 'civicrm_custom_field',
361 'entity' => 'CustomField',
362 'bao' => 'CRM_Core_BAO_CustomField',
367 'pseudoconstant' => [
368 'callback' => 'CRM_Core_BAO_CustomField::dataType',
373 'name' => 'html_type',
374 'type' => CRM_Utils_Type
::T_STRING
,
375 'title' => ts('Custom Field HTML Type'),
376 'description' => ts('HTML types plus several built-in extended types.'),
379 'size' => CRM_Utils_Type
::MEDIUM
,
380 'where' => 'civicrm_custom_field.html_type',
381 'table_name' => 'civicrm_custom_field',
382 'entity' => 'CustomField',
383 'bao' => 'CRM_Core_BAO_CustomField',
385 'pseudoconstant' => [
386 'callback' => 'CRM_Core_SelectValues::customHtmlType',
391 'name' => 'default_value',
392 'type' => CRM_Utils_Type
::T_STRING
,
393 'title' => ts('Custom Field Default'),
394 'description' => ts('Use form_options.is_default for field_types which use options.'),
396 'size' => CRM_Utils_Type
::HUGE
,
397 'where' => 'civicrm_custom_field.default_value',
398 'table_name' => 'civicrm_custom_field',
399 'entity' => 'CustomField',
400 'bao' => 'CRM_Core_BAO_CustomField',
405 'name' => 'is_required',
406 'type' => CRM_Utils_Type
::T_BOOLEAN
,
407 'title' => ts('Custom Field Is Required?'),
408 'description' => ts('Is a value required for this property.'),
409 'where' => 'civicrm_custom_field.is_required',
411 'table_name' => 'civicrm_custom_field',
412 'entity' => 'CustomField',
413 'bao' => 'CRM_Core_BAO_CustomField',
418 'name' => 'is_searchable',
419 'type' => CRM_Utils_Type
::T_BOOLEAN
,
420 'title' => ts('Allow Searching on Field?'),
421 'description' => ts('Is this property searchable.'),
422 'where' => 'civicrm_custom_field.is_searchable',
424 'table_name' => 'civicrm_custom_field',
425 'entity' => 'CustomField',
426 'bao' => 'CRM_Core_BAO_CustomField',
430 'is_search_range' => [
431 'name' => 'is_search_range',
432 'type' => CRM_Utils_Type
::T_BOOLEAN
,
433 'title' => ts('Search as a Range'),
434 'description' => ts('Is this property range searchable.'),
435 'where' => 'civicrm_custom_field.is_search_range',
437 'table_name' => 'civicrm_custom_field',
438 'entity' => 'CustomField',
439 'bao' => 'CRM_Core_BAO_CustomField',
445 'type' => CRM_Utils_Type
::T_INT
,
446 'title' => ts('Order'),
447 'description' => ts('Controls field display order within an extended property group.'),
449 'where' => 'civicrm_custom_field.weight',
451 'table_name' => 'civicrm_custom_field',
452 'entity' => 'CustomField',
453 'bao' => 'CRM_Core_BAO_CustomField',
458 'name' => 'help_pre',
459 'type' => CRM_Utils_Type
::T_TEXT
,
460 'title' => ts('Custom Field Pre Text'),
461 'description' => ts('Description and/or help text to display before this field.'),
462 'where' => 'civicrm_custom_field.help_pre',
463 'table_name' => 'civicrm_custom_field',
464 'entity' => 'CustomField',
465 'bao' => 'CRM_Core_BAO_CustomField',
470 'name' => 'help_post',
471 'type' => CRM_Utils_Type
::T_TEXT
,
472 'title' => ts('Custom Field Post Text'),
473 'description' => ts('Description and/or help text to display after this field.'),
474 'where' => 'civicrm_custom_field.help_post',
475 'table_name' => 'civicrm_custom_field',
476 'entity' => 'CustomField',
477 'bao' => 'CRM_Core_BAO_CustomField',
483 'type' => CRM_Utils_Type
::T_STRING
,
484 'title' => ts('Custom Field Formatting'),
485 'description' => ts('Optional format instructions for specific field types, like date types.'),
487 'size' => CRM_Utils_Type
::BIG
,
488 'where' => 'civicrm_custom_field.mask',
489 'table_name' => 'civicrm_custom_field',
490 'entity' => 'CustomField',
491 'bao' => 'CRM_Core_BAO_CustomField',
496 'name' => 'attributes',
497 'type' => CRM_Utils_Type
::T_STRING
,
498 'title' => ts('Custom Field Attributes'),
499 'description' => ts('Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes'),
501 'size' => CRM_Utils_Type
::HUGE
,
502 'where' => 'civicrm_custom_field.attributes',
503 'table_name' => 'civicrm_custom_field',
504 'entity' => 'CustomField',
505 'bao' => 'CRM_Core_BAO_CustomField',
510 'name' => 'javascript',
511 'type' => CRM_Utils_Type
::T_STRING
,
512 'title' => ts('Custom Field Javascript'),
513 'description' => ts('Optional scripting attributes for field.'),
515 'size' => CRM_Utils_Type
::HUGE
,
516 'where' => 'civicrm_custom_field.javascript',
517 'table_name' => 'civicrm_custom_field',
518 'entity' => 'CustomField',
519 'bao' => 'CRM_Core_BAO_CustomField',
524 'name' => 'is_active',
525 'type' => CRM_Utils_Type
::T_BOOLEAN
,
526 'title' => ts('Custom Field Is Active?'),
527 'description' => ts('Is this property active?'),
528 'where' => 'civicrm_custom_field.is_active',
530 'table_name' => 'civicrm_custom_field',
531 'entity' => 'CustomField',
532 'bao' => 'CRM_Core_BAO_CustomField',
538 'type' => CRM_Utils_Type
::T_BOOLEAN
,
539 'title' => ts('Field is Viewable'),
540 'description' => ts('Is this property set by PHP Code? A code field is viewable but not editable'),
541 'where' => 'civicrm_custom_field.is_view',
543 'table_name' => 'civicrm_custom_field',
544 'entity' => 'CustomField',
545 'bao' => 'CRM_Core_BAO_CustomField',
549 'options_per_line' => [
550 'name' => 'options_per_line',
551 'type' => CRM_Utils_Type
::T_INT
,
552 'title' => ts('Field Options Per Line'),
553 'description' => ts('number of options per line for checkbox and radio'),
554 'where' => 'civicrm_custom_field.options_per_line',
555 'table_name' => 'civicrm_custom_field',
556 'entity' => 'CustomField',
557 'bao' => 'CRM_Core_BAO_CustomField',
562 'name' => 'text_length',
563 'type' => CRM_Utils_Type
::T_INT
,
564 'title' => ts('Field Length'),
565 'description' => ts('field length if alphanumeric'),
566 'where' => 'civicrm_custom_field.text_length',
567 'table_name' => 'civicrm_custom_field',
568 'entity' => 'CustomField',
569 'bao' => 'CRM_Core_BAO_CustomField',
573 'start_date_years' => [
574 'name' => 'start_date_years',
575 'type' => CRM_Utils_Type
::T_INT
,
576 'title' => ts('Field Start Date'),
577 'description' => ts('Date may be up to start_date_years years prior to the current date.'),
578 'where' => 'civicrm_custom_field.start_date_years',
579 'table_name' => 'civicrm_custom_field',
580 'entity' => 'CustomField',
581 'bao' => 'CRM_Core_BAO_CustomField',
585 'end_date_years' => [
586 'name' => 'end_date_years',
587 'type' => CRM_Utils_Type
::T_INT
,
588 'title' => ts('Field End Date'),
589 'description' => ts('Date may be up to end_date_years years after the current date.'),
590 'where' => 'civicrm_custom_field.end_date_years',
591 'table_name' => 'civicrm_custom_field',
592 'entity' => 'CustomField',
593 'bao' => 'CRM_Core_BAO_CustomField',
598 'name' => 'date_format',
599 'type' => CRM_Utils_Type
::T_STRING
,
600 'title' => ts('Field Data Format'),
601 'description' => ts('date format for custom date'),
603 'size' => CRM_Utils_Type
::BIG
,
604 'where' => 'civicrm_custom_field.date_format',
605 'table_name' => 'civicrm_custom_field',
606 'entity' => 'CustomField',
607 'bao' => 'CRM_Core_BAO_CustomField',
609 'pseudoconstant' => [
610 'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats',
615 'name' => 'time_format',
616 'type' => CRM_Utils_Type
::T_INT
,
617 'title' => ts('Field Time Format'),
618 'description' => ts('time format for custom date'),
619 'where' => 'civicrm_custom_field.time_format',
620 'table_name' => 'civicrm_custom_field',
621 'entity' => 'CustomField',
622 'bao' => 'CRM_Core_BAO_CustomField',
624 'pseudoconstant' => [
625 'callback' => 'CRM_Core_SelectValues::getTimeFormats',
630 'name' => 'note_columns',
631 'type' => CRM_Utils_Type
::T_INT
,
632 'title' => ts('Field Note Columns'),
633 'description' => ts('Number of columns in Note Field'),
634 'where' => 'civicrm_custom_field.note_columns',
635 'table_name' => 'civicrm_custom_field',
636 'entity' => 'CustomField',
637 'bao' => 'CRM_Core_BAO_CustomField',
642 'name' => 'note_rows',
643 'type' => CRM_Utils_Type
::T_INT
,
644 'title' => ts('Field Note Rows'),
645 'description' => ts('Number of rows in Note Field'),
646 'where' => 'civicrm_custom_field.note_rows',
647 'table_name' => 'civicrm_custom_field',
648 'entity' => 'CustomField',
649 'bao' => 'CRM_Core_BAO_CustomField',
654 'name' => 'column_name',
655 'type' => CRM_Utils_Type
::T_STRING
,
656 'title' => ts('Field Column Name'),
657 'description' => ts('Name of the column that holds the values for this field.'),
659 'size' => CRM_Utils_Type
::HUGE
,
660 'where' => 'civicrm_custom_field.column_name',
661 'table_name' => 'civicrm_custom_field',
662 'entity' => 'CustomField',
663 'bao' => 'CRM_Core_BAO_CustomField',
667 'option_group_id' => [
668 'name' => 'option_group_id',
669 'type' => CRM_Utils_Type
::T_INT
,
670 'title' => ts('Field Option Group'),
671 'description' => ts('For elements with options, the option group id that is used'),
672 'where' => 'civicrm_custom_field.option_group_id',
673 'table_name' => 'civicrm_custom_field',
674 'entity' => 'CustomField',
675 'bao' => 'CRM_Core_BAO_CustomField',
677 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
678 'pseudoconstant' => [
679 'table' => 'civicrm_option_group',
681 'labelColumn' => 'title',
686 'name' => 'serialize',
687 'type' => CRM_Utils_Type
::T_INT
,
688 'title' => ts('Serialize'),
689 'description' => ts('Serialization method - a non-null value indicates a multi-valued field.'),
690 'where' => 'civicrm_custom_field.serialize',
691 'table_name' => 'civicrm_custom_field',
692 'entity' => 'CustomField',
693 'bao' => 'CRM_Core_BAO_CustomField',
695 'pseudoconstant' => [
696 'callback' => 'CRM_Core_SelectValues::fieldSerialization',
702 'type' => CRM_Utils_Type
::T_STRING
,
703 'title' => ts('Field Filter'),
704 'description' => ts('Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.'),
706 'size' => CRM_Utils_Type
::HUGE
,
707 'where' => 'civicrm_custom_field.filter',
708 'table_name' => 'civicrm_custom_field',
709 'entity' => 'CustomField',
710 'bao' => 'CRM_Core_BAO_CustomField',
715 'name' => 'in_selector',
716 'type' => CRM_Utils_Type
::T_BOOLEAN
,
717 'title' => ts('Field Display'),
718 'description' => ts('Should the multi-record custom field values be displayed in tab table listing'),
719 'where' => 'civicrm_custom_field.in_selector',
721 'table_name' => 'civicrm_custom_field',
722 'entity' => 'CustomField',
723 'bao' => 'CRM_Core_BAO_CustomField',
728 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
730 return Civi
::$statics[__CLASS__
]['fields'];
734 * Return a mapping from field-name to the corresponding key (as used in fields()).
737 * Array(string $name => string $uniqueName).
739 public static function &fieldKeys() {
740 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
741 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
743 return Civi
::$statics[__CLASS__
]['fieldKeys'];
747 * Returns the names of this table
751 public static function getTableName() {
752 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
756 * Returns if this table needs to be logged
760 public function getLog() {
765 * Returns the list of fields that can be imported
767 * @param bool $prefix
771 public static function &import($prefix = FALSE) {
772 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'custom_field', $prefix, []);
777 * Returns the list of fields that can be exported
779 * @param bool $prefix
783 public static function &export($prefix = FALSE) {
784 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'custom_field', $prefix, []);
789 * Returns the list of indices
791 * @param bool $localize
795 public static function indices($localize = TRUE) {
797 'UI_label_custom_group_id' => [
798 'name' => 'UI_label_custom_group_id',
801 1 => 'custom_group_id',
803 'localizable' => TRUE,
805 'sig' => 'civicrm_custom_field::1::label::custom_group_id',
807 'UI_name_custom_group_id' => [
808 'name' => 'UI_name_custom_group_id',
811 1 => 'custom_group_id',
813 'localizable' => FALSE,
815 'sig' => 'civicrm_custom_field::1::name::custom_group_id',
818 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;