5 * @copyright CiviCRM LLC (c) 2004-2018
7 * Generated from xml/schema/CRM/Core/CustomField.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:7f096c92af68ef9564675e3d708fbbe1)
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 static $_tableName = 'civicrm_custom_field';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
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 * Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.
235 * Should the multi-record custom field values be displayed in tab table listing
244 public function __construct() {
245 $this->__table
= 'civicrm_custom_field';
246 parent
::__construct();
250 * Returns foreign keys and entity references.
253 * [CRM_Core_Reference_Interface]
255 public static function getReferenceColumns() {
256 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
257 Civi
::$statics[__CLASS__
]['links'] = static ::createReferenceColumns(__CLASS__
);
258 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'custom_group_id', 'civicrm_custom_group', 'id');
259 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
261 return Civi
::$statics[__CLASS__
]['links'];
265 * Returns all the column names of this table
269 public static function &fields() {
270 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
271 Civi
::$statics[__CLASS__
]['fields'] = [
274 'type' => CRM_Utils_Type
::T_INT
,
275 'title' => ts('Custom Field ID'),
276 'description' => 'Unique Custom Field ID',
278 'table_name' => 'civicrm_custom_field',
279 'entity' => 'CustomField',
280 'bao' => 'CRM_Core_BAO_CustomField',
283 'custom_group_id' => [
284 'name' => 'custom_group_id',
285 'type' => CRM_Utils_Type
::T_INT
,
286 'title' => ts('Custom Group'),
287 'description' => 'FK to civicrm_custom_group.',
289 'table_name' => 'civicrm_custom_field',
290 'entity' => 'CustomField',
291 'bao' => 'CRM_Core_BAO_CustomField',
293 'FKClassName' => 'CRM_Core_DAO_CustomGroup',
297 'pseudoconstant' => [
298 'table' => 'civicrm_custom_group',
300 'labelColumn' => 'title',
305 'type' => CRM_Utils_Type
::T_STRING
,
306 'title' => ts('Custom Field Name'),
307 'description' => 'Variable name/programmatic handle for this group.',
309 'size' => CRM_Utils_Type
::BIG
,
310 'table_name' => 'civicrm_custom_field',
311 'entity' => 'CustomField',
312 'bao' => 'CRM_Core_BAO_CustomField',
317 'type' => CRM_Utils_Type
::T_STRING
,
318 'title' => ts('Custom Field Label'),
319 'description' => 'Text for form field label (also friendly name for administering this custom property).',
322 'size' => CRM_Utils_Type
::HUGE
,
323 'table_name' => 'civicrm_custom_field',
324 'entity' => 'CustomField',
325 'bao' => 'CRM_Core_BAO_CustomField',
329 'name' => 'data_type',
330 'type' => CRM_Utils_Type
::T_STRING
,
331 'title' => ts('Custom Field Data Type'),
332 'description' => 'Controls location of data storage in extended_data table.',
335 'size' => CRM_Utils_Type
::TWELVE
,
336 'table_name' => 'civicrm_custom_field',
337 'entity' => 'CustomField',
338 'bao' => 'CRM_Core_BAO_CustomField',
343 'pseudoconstant' => [
344 'callback' => 'CRM_Core_BAO_CustomField::dataType',
348 'name' => 'html_type',
349 'type' => CRM_Utils_Type
::T_STRING
,
350 'title' => ts('Custom Field HTML Type'),
351 'description' => 'HTML types plus several built-in extended types.',
354 'size' => CRM_Utils_Type
::MEDIUM
,
355 'table_name' => 'civicrm_custom_field',
356 'entity' => 'CustomField',
357 'bao' => 'CRM_Core_BAO_CustomField',
359 'pseudoconstant' => [
360 'callback' => 'CRM_Core_SelectValues::customHtmlType',
364 'name' => 'default_value',
365 'type' => CRM_Utils_Type
::T_STRING
,
366 'title' => ts('Custom Field Default'),
367 'description' => 'Use form_options.is_default for field_types which use options.',
369 'size' => CRM_Utils_Type
::HUGE
,
370 'table_name' => 'civicrm_custom_field',
371 'entity' => 'CustomField',
372 'bao' => 'CRM_Core_BAO_CustomField',
376 'name' => 'is_required',
377 'type' => CRM_Utils_Type
::T_BOOLEAN
,
378 'title' => ts('Custom Field Is Required?'),
379 'description' => 'Is a value required for this property.',
380 'table_name' => 'civicrm_custom_field',
381 'entity' => 'CustomField',
382 'bao' => 'CRM_Core_BAO_CustomField',
386 'name' => 'is_searchable',
387 'type' => CRM_Utils_Type
::T_BOOLEAN
,
388 'title' => ts('Allow Searching on Field?'),
389 'description' => 'Is this property searchable.',
390 'table_name' => 'civicrm_custom_field',
391 'entity' => 'CustomField',
392 'bao' => 'CRM_Core_BAO_CustomField',
395 'is_search_range' => [
396 'name' => 'is_search_range',
397 'type' => CRM_Utils_Type
::T_BOOLEAN
,
398 'title' => ts('Search as a Range'),
399 'description' => 'Is this property range searchable.',
400 'table_name' => 'civicrm_custom_field',
401 'entity' => 'CustomField',
402 'bao' => 'CRM_Core_BAO_CustomField',
407 'type' => CRM_Utils_Type
::T_INT
,
408 'title' => ts('Order'),
409 'description' => 'Controls field display order within an extended property group.',
412 'table_name' => 'civicrm_custom_field',
413 'entity' => 'CustomField',
414 'bao' => 'CRM_Core_BAO_CustomField',
418 'name' => 'help_pre',
419 'type' => CRM_Utils_Type
::T_TEXT
,
420 'title' => ts('Custom Field Pre Text'),
421 'description' => 'Description and/or help text to display before this field.',
422 'table_name' => 'civicrm_custom_field',
423 'entity' => 'CustomField',
424 'bao' => 'CRM_Core_BAO_CustomField',
428 'name' => 'help_post',
429 'type' => CRM_Utils_Type
::T_TEXT
,
430 'title' => ts('Custom Field Post Text'),
431 'description' => 'Description and/or help text to display after this field.',
432 'table_name' => 'civicrm_custom_field',
433 'entity' => 'CustomField',
434 'bao' => 'CRM_Core_BAO_CustomField',
439 'type' => CRM_Utils_Type
::T_STRING
,
440 'title' => ts('Custom Field Formatting'),
441 'description' => 'Optional format instructions for specific field types, like date types.',
443 'size' => CRM_Utils_Type
::BIG
,
444 'table_name' => 'civicrm_custom_field',
445 'entity' => 'CustomField',
446 'bao' => 'CRM_Core_BAO_CustomField',
450 'name' => 'attributes',
451 'type' => CRM_Utils_Type
::T_STRING
,
452 'title' => ts('Custom Field Attributes'),
453 'description' => 'Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes',
455 'size' => CRM_Utils_Type
::HUGE
,
456 'table_name' => 'civicrm_custom_field',
457 'entity' => 'CustomField',
458 'bao' => 'CRM_Core_BAO_CustomField',
462 'name' => 'javascript',
463 'type' => CRM_Utils_Type
::T_STRING
,
464 'title' => ts('Custom Field Javascript'),
465 'description' => 'Optional scripting attributes for field.',
467 'size' => CRM_Utils_Type
::HUGE
,
468 'table_name' => 'civicrm_custom_field',
469 'entity' => 'CustomField',
470 'bao' => 'CRM_Core_BAO_CustomField',
474 'name' => 'is_active',
475 'type' => CRM_Utils_Type
::T_BOOLEAN
,
476 'title' => ts('Custom Field Is Active?'),
477 'description' => 'Is this property active?',
479 'table_name' => 'civicrm_custom_field',
480 'entity' => 'CustomField',
481 'bao' => 'CRM_Core_BAO_CustomField',
486 'type' => CRM_Utils_Type
::T_BOOLEAN
,
487 'title' => ts('Field is Viewable'),
488 'description' => 'Is this property set by PHP Code? A code field is viewable but not editable',
489 'table_name' => 'civicrm_custom_field',
490 'entity' => 'CustomField',
491 'bao' => 'CRM_Core_BAO_CustomField',
494 'options_per_line' => [
495 'name' => 'options_per_line',
496 'type' => CRM_Utils_Type
::T_INT
,
497 'title' => ts('Field Options Per Line'),
498 'description' => 'number of options per line for checkbox and radio',
499 'table_name' => 'civicrm_custom_field',
500 'entity' => 'CustomField',
501 'bao' => 'CRM_Core_BAO_CustomField',
505 'name' => 'text_length',
506 'type' => CRM_Utils_Type
::T_INT
,
507 'title' => ts('Field Length'),
508 'description' => 'field length if alphanumeric',
509 'table_name' => 'civicrm_custom_field',
510 'entity' => 'CustomField',
511 'bao' => 'CRM_Core_BAO_CustomField',
514 'start_date_years' => [
515 'name' => 'start_date_years',
516 'type' => CRM_Utils_Type
::T_INT
,
517 'title' => ts('Field Start Date'),
518 'description' => 'Date may be up to start_date_years years prior to the current date.',
519 'table_name' => 'civicrm_custom_field',
520 'entity' => 'CustomField',
521 'bao' => 'CRM_Core_BAO_CustomField',
524 'end_date_years' => [
525 'name' => 'end_date_years',
526 'type' => CRM_Utils_Type
::T_INT
,
527 'title' => ts('Field End Date'),
528 'description' => 'Date may be up to end_date_years years after the current date.',
529 'table_name' => 'civicrm_custom_field',
530 'entity' => 'CustomField',
531 'bao' => 'CRM_Core_BAO_CustomField',
535 'name' => 'date_format',
536 'type' => CRM_Utils_Type
::T_STRING
,
537 'title' => ts('Field Data Format'),
538 'description' => 'date format for custom date',
540 'size' => CRM_Utils_Type
::BIG
,
541 'table_name' => 'civicrm_custom_field',
542 'entity' => 'CustomField',
543 'bao' => 'CRM_Core_BAO_CustomField',
547 'name' => 'time_format',
548 'type' => CRM_Utils_Type
::T_INT
,
549 'title' => ts('Field Time Format'),
550 'description' => 'time format for custom date',
551 'table_name' => 'civicrm_custom_field',
552 'entity' => 'CustomField',
553 'bao' => 'CRM_Core_BAO_CustomField',
557 'name' => 'note_columns',
558 'type' => CRM_Utils_Type
::T_INT
,
559 'title' => ts('Field Note Columns'),
560 'description' => ' Number of columns in Note Field ',
561 'table_name' => 'civicrm_custom_field',
562 'entity' => 'CustomField',
563 'bao' => 'CRM_Core_BAO_CustomField',
567 'name' => 'note_rows',
568 'type' => CRM_Utils_Type
::T_INT
,
569 'title' => ts('Field Note Rows'),
570 'description' => ' Number of rows in Note Field ',
571 'table_name' => 'civicrm_custom_field',
572 'entity' => 'CustomField',
573 'bao' => 'CRM_Core_BAO_CustomField',
577 'name' => 'column_name',
578 'type' => CRM_Utils_Type
::T_STRING
,
579 'title' => ts('Field Column Name'),
580 'description' => 'Name of the column that holds the values for this field.',
582 'size' => CRM_Utils_Type
::HUGE
,
583 'table_name' => 'civicrm_custom_field',
584 'entity' => 'CustomField',
585 'bao' => 'CRM_Core_BAO_CustomField',
588 'option_group_id' => [
589 'name' => 'option_group_id',
590 'type' => CRM_Utils_Type
::T_INT
,
591 'title' => ts('Field Option Group'),
592 'description' => 'For elements with options, the option group id that is used',
593 'table_name' => 'civicrm_custom_field',
594 'entity' => 'CustomField',
595 'bao' => 'CRM_Core_BAO_CustomField',
597 'pseudoconstant' => [
598 'table' => 'civicrm_option_group',
600 'labelColumn' => 'title',
605 'type' => CRM_Utils_Type
::T_STRING
,
606 'title' => ts('Field Filter'),
607 'description' => 'Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.',
609 'size' => CRM_Utils_Type
::HUGE
,
610 'table_name' => 'civicrm_custom_field',
611 'entity' => 'CustomField',
612 'bao' => 'CRM_Core_BAO_CustomField',
616 'name' => 'in_selector',
617 'type' => CRM_Utils_Type
::T_BOOLEAN
,
618 'title' => ts('Field Display'),
619 'description' => 'Should the multi-record custom field values be displayed in tab table listing',
620 'table_name' => 'civicrm_custom_field',
621 'entity' => 'CustomField',
622 'bao' => 'CRM_Core_BAO_CustomField',
626 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
628 return Civi
::$statics[__CLASS__
]['fields'];
632 * Return a mapping from field-name to the corresponding key (as used in fields()).
635 * Array(string $name => string $uniqueName).
637 public static function &fieldKeys() {
638 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
639 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
641 return Civi
::$statics[__CLASS__
]['fieldKeys'];
645 * Returns the names of this table
649 public static function getTableName() {
650 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
654 * Returns if this table needs to be logged
658 public function getLog() {
663 * Returns the list of fields that can be imported
665 * @param bool $prefix
669 public static function &import($prefix = FALSE) {
670 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'custom_field', $prefix, []);
675 * Returns the list of fields that can be exported
677 * @param bool $prefix
681 public static function &export($prefix = FALSE) {
682 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'custom_field', $prefix, []);
687 * Returns the list of indices
689 * @param bool $localize
693 public static function indices($localize = TRUE) {
695 'UI_label_custom_group_id' => [
696 'name' => 'UI_label_custom_group_id',
699 1 => 'custom_group_id',
701 'localizable' => TRUE,
703 'sig' => 'civicrm_custom_field::1::label::custom_group_id',
705 'UI_name_custom_group_id' => [
706 'name' => 'UI_name_custom_group_id',
709 1 => 'custom_group_id',
711 'localizable' => FALSE,
713 'sig' => 'civicrm_custom_field::1::name::custom_group_id',
716 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;