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:73d7ccebba6055cae4fa0c9d797025c4)
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 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'option_group_id', 'civicrm_option_group', 'id');
260 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
262 return Civi
::$statics[__CLASS__
]['links'];
266 * Returns all the column names of this table
270 public static function &fields() {
271 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
272 Civi
::$statics[__CLASS__
]['fields'] = [
275 'type' => CRM_Utils_Type
::T_INT
,
276 'title' => ts('Custom Field ID'),
277 'description' => ts('Unique Custom Field ID'),
279 'table_name' => 'civicrm_custom_field',
280 'entity' => 'CustomField',
281 'bao' => 'CRM_Core_BAO_CustomField',
284 'custom_group_id' => [
285 'name' => 'custom_group_id',
286 'type' => CRM_Utils_Type
::T_INT
,
287 'title' => ts('Custom Group'),
288 'description' => ts('FK to civicrm_custom_group.'),
290 'table_name' => 'civicrm_custom_field',
291 'entity' => 'CustomField',
292 'bao' => 'CRM_Core_BAO_CustomField',
294 'FKClassName' => 'CRM_Core_DAO_CustomGroup',
298 'pseudoconstant' => [
299 'table' => 'civicrm_custom_group',
301 'labelColumn' => 'title',
306 'type' => CRM_Utils_Type
::T_STRING
,
307 'title' => ts('Custom Field Name'),
308 'description' => ts('Variable name/programmatic handle for this group.'),
310 'size' => CRM_Utils_Type
::BIG
,
311 'table_name' => 'civicrm_custom_field',
312 'entity' => 'CustomField',
313 'bao' => 'CRM_Core_BAO_CustomField',
318 'type' => CRM_Utils_Type
::T_STRING
,
319 'title' => ts('Custom Field Label'),
320 'description' => ts('Text for form field label (also friendly name for administering this custom property).'),
323 'size' => CRM_Utils_Type
::HUGE
,
324 'table_name' => 'civicrm_custom_field',
325 'entity' => 'CustomField',
326 'bao' => 'CRM_Core_BAO_CustomField',
330 'name' => 'data_type',
331 'type' => CRM_Utils_Type
::T_STRING
,
332 'title' => ts('Custom Field Data Type'),
333 'description' => ts('Controls location of data storage in extended_data table.'),
336 'size' => CRM_Utils_Type
::TWELVE
,
337 'table_name' => 'civicrm_custom_field',
338 'entity' => 'CustomField',
339 'bao' => 'CRM_Core_BAO_CustomField',
344 'pseudoconstant' => [
345 'callback' => 'CRM_Core_BAO_CustomField::dataType',
349 'name' => 'html_type',
350 'type' => CRM_Utils_Type
::T_STRING
,
351 'title' => ts('Custom Field HTML Type'),
352 'description' => ts('HTML types plus several built-in extended types.'),
355 'size' => CRM_Utils_Type
::MEDIUM
,
356 'table_name' => 'civicrm_custom_field',
357 'entity' => 'CustomField',
358 'bao' => 'CRM_Core_BAO_CustomField',
360 'pseudoconstant' => [
361 'callback' => 'CRM_Core_SelectValues::customHtmlType',
365 'name' => 'default_value',
366 'type' => CRM_Utils_Type
::T_STRING
,
367 'title' => ts('Custom Field Default'),
368 'description' => ts('Use form_options.is_default for field_types which use options.'),
370 'size' => CRM_Utils_Type
::HUGE
,
371 'table_name' => 'civicrm_custom_field',
372 'entity' => 'CustomField',
373 'bao' => 'CRM_Core_BAO_CustomField',
377 'name' => 'is_required',
378 'type' => CRM_Utils_Type
::T_BOOLEAN
,
379 'title' => ts('Custom Field Is Required?'),
380 'description' => ts('Is a value required for this property.'),
382 'table_name' => 'civicrm_custom_field',
383 'entity' => 'CustomField',
384 'bao' => 'CRM_Core_BAO_CustomField',
388 'name' => 'is_searchable',
389 'type' => CRM_Utils_Type
::T_BOOLEAN
,
390 'title' => ts('Allow Searching on Field?'),
391 'description' => ts('Is this property searchable.'),
393 'table_name' => 'civicrm_custom_field',
394 'entity' => 'CustomField',
395 'bao' => 'CRM_Core_BAO_CustomField',
398 'is_search_range' => [
399 'name' => 'is_search_range',
400 'type' => CRM_Utils_Type
::T_BOOLEAN
,
401 'title' => ts('Search as a Range'),
402 'description' => ts('Is this property range searchable.'),
404 'table_name' => 'civicrm_custom_field',
405 'entity' => 'CustomField',
406 'bao' => 'CRM_Core_BAO_CustomField',
411 'type' => CRM_Utils_Type
::T_INT
,
412 'title' => ts('Order'),
413 'description' => ts('Controls field display order within an extended property group.'),
416 'table_name' => 'civicrm_custom_field',
417 'entity' => 'CustomField',
418 'bao' => 'CRM_Core_BAO_CustomField',
422 'name' => 'help_pre',
423 'type' => CRM_Utils_Type
::T_TEXT
,
424 'title' => ts('Custom Field Pre Text'),
425 'description' => ts('Description and/or help text to display before this field.'),
426 'table_name' => 'civicrm_custom_field',
427 'entity' => 'CustomField',
428 'bao' => 'CRM_Core_BAO_CustomField',
432 'name' => 'help_post',
433 'type' => CRM_Utils_Type
::T_TEXT
,
434 'title' => ts('Custom Field Post Text'),
435 'description' => ts('Description and/or help text to display after this field.'),
436 'table_name' => 'civicrm_custom_field',
437 'entity' => 'CustomField',
438 'bao' => 'CRM_Core_BAO_CustomField',
443 'type' => CRM_Utils_Type
::T_STRING
,
444 'title' => ts('Custom Field Formatting'),
445 'description' => ts('Optional format instructions for specific field types, like date types.'),
447 'size' => CRM_Utils_Type
::BIG
,
448 'table_name' => 'civicrm_custom_field',
449 'entity' => 'CustomField',
450 'bao' => 'CRM_Core_BAO_CustomField',
454 'name' => 'attributes',
455 'type' => CRM_Utils_Type
::T_STRING
,
456 'title' => ts('Custom Field Attributes'),
457 'description' => ts('Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes'),
459 'size' => CRM_Utils_Type
::HUGE
,
460 'table_name' => 'civicrm_custom_field',
461 'entity' => 'CustomField',
462 'bao' => 'CRM_Core_BAO_CustomField',
466 'name' => 'javascript',
467 'type' => CRM_Utils_Type
::T_STRING
,
468 'title' => ts('Custom Field Javascript'),
469 'description' => ts('Optional scripting attributes for field.'),
471 'size' => CRM_Utils_Type
::HUGE
,
472 'table_name' => 'civicrm_custom_field',
473 'entity' => 'CustomField',
474 'bao' => 'CRM_Core_BAO_CustomField',
478 'name' => 'is_active',
479 'type' => CRM_Utils_Type
::T_BOOLEAN
,
480 'title' => ts('Custom Field Is Active?'),
481 'description' => ts('Is this property active?'),
483 'table_name' => 'civicrm_custom_field',
484 'entity' => 'CustomField',
485 'bao' => 'CRM_Core_BAO_CustomField',
490 'type' => CRM_Utils_Type
::T_BOOLEAN
,
491 'title' => ts('Field is Viewable'),
492 'description' => ts('Is this property set by PHP Code? A code field is viewable but not editable'),
494 'table_name' => 'civicrm_custom_field',
495 'entity' => 'CustomField',
496 'bao' => 'CRM_Core_BAO_CustomField',
499 'options_per_line' => [
500 'name' => 'options_per_line',
501 'type' => CRM_Utils_Type
::T_INT
,
502 'title' => ts('Field Options Per Line'),
503 'description' => ts('number of options per line for checkbox and radio'),
504 'table_name' => 'civicrm_custom_field',
505 'entity' => 'CustomField',
506 'bao' => 'CRM_Core_BAO_CustomField',
510 'name' => 'text_length',
511 'type' => CRM_Utils_Type
::T_INT
,
512 'title' => ts('Field Length'),
513 'description' => ts('field length if alphanumeric'),
514 'table_name' => 'civicrm_custom_field',
515 'entity' => 'CustomField',
516 'bao' => 'CRM_Core_BAO_CustomField',
519 'start_date_years' => [
520 'name' => 'start_date_years',
521 'type' => CRM_Utils_Type
::T_INT
,
522 'title' => ts('Field Start Date'),
523 'description' => ts('Date may be up to start_date_years years prior to the current date.'),
524 'table_name' => 'civicrm_custom_field',
525 'entity' => 'CustomField',
526 'bao' => 'CRM_Core_BAO_CustomField',
529 'end_date_years' => [
530 'name' => 'end_date_years',
531 'type' => CRM_Utils_Type
::T_INT
,
532 'title' => ts('Field End Date'),
533 'description' => ts('Date may be up to end_date_years years after the current date.'),
534 'table_name' => 'civicrm_custom_field',
535 'entity' => 'CustomField',
536 'bao' => 'CRM_Core_BAO_CustomField',
540 'name' => 'date_format',
541 'type' => CRM_Utils_Type
::T_STRING
,
542 'title' => ts('Field Data Format'),
543 'description' => ts('date format for custom date'),
545 'size' => CRM_Utils_Type
::BIG
,
546 'table_name' => 'civicrm_custom_field',
547 'entity' => 'CustomField',
548 'bao' => 'CRM_Core_BAO_CustomField',
552 'name' => 'time_format',
553 'type' => CRM_Utils_Type
::T_INT
,
554 'title' => ts('Field Time Format'),
555 'description' => ts('time format for custom date'),
556 'table_name' => 'civicrm_custom_field',
557 'entity' => 'CustomField',
558 'bao' => 'CRM_Core_BAO_CustomField',
562 'name' => 'note_columns',
563 'type' => CRM_Utils_Type
::T_INT
,
564 'title' => ts('Field Note Columns'),
565 'description' => ts(' Number of columns in Note Field '),
566 'table_name' => 'civicrm_custom_field',
567 'entity' => 'CustomField',
568 'bao' => 'CRM_Core_BAO_CustomField',
572 'name' => 'note_rows',
573 'type' => CRM_Utils_Type
::T_INT
,
574 'title' => ts('Field Note Rows'),
575 'description' => ts(' Number of rows in Note Field '),
576 'table_name' => 'civicrm_custom_field',
577 'entity' => 'CustomField',
578 'bao' => 'CRM_Core_BAO_CustomField',
582 'name' => 'column_name',
583 'type' => CRM_Utils_Type
::T_STRING
,
584 'title' => ts('Field Column Name'),
585 'description' => ts('Name of the column that holds the values for this field.'),
587 'size' => CRM_Utils_Type
::HUGE
,
588 'table_name' => 'civicrm_custom_field',
589 'entity' => 'CustomField',
590 'bao' => 'CRM_Core_BAO_CustomField',
593 'option_group_id' => [
594 'name' => 'option_group_id',
595 'type' => CRM_Utils_Type
::T_INT
,
596 'title' => ts('Field Option Group'),
597 'description' => ts('For elements with options, the option group id that is used'),
598 'table_name' => 'civicrm_custom_field',
599 'entity' => 'CustomField',
600 'bao' => 'CRM_Core_BAO_CustomField',
602 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
603 'pseudoconstant' => [
604 'table' => 'civicrm_option_group',
606 'labelColumn' => 'title',
611 'type' => CRM_Utils_Type
::T_STRING
,
612 'title' => ts('Field Filter'),
613 'description' => ts('Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.'),
615 'size' => CRM_Utils_Type
::HUGE
,
616 'table_name' => 'civicrm_custom_field',
617 'entity' => 'CustomField',
618 'bao' => 'CRM_Core_BAO_CustomField',
622 'name' => 'in_selector',
623 'type' => CRM_Utils_Type
::T_BOOLEAN
,
624 'title' => ts('Field Display'),
625 'description' => ts('Should the multi-record custom field values be displayed in tab table listing'),
627 'table_name' => 'civicrm_custom_field',
628 'entity' => 'CustomField',
629 'bao' => 'CRM_Core_BAO_CustomField',
633 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
635 return Civi
::$statics[__CLASS__
]['fields'];
639 * Return a mapping from field-name to the corresponding key (as used in fields()).
642 * Array(string $name => string $uniqueName).
644 public static function &fieldKeys() {
645 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
646 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
648 return Civi
::$statics[__CLASS__
]['fieldKeys'];
652 * Returns the names of this table
656 public static function getTableName() {
657 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
661 * Returns if this table needs to be logged
665 public function getLog() {
670 * Returns the list of fields that can be imported
672 * @param bool $prefix
676 public static function &import($prefix = FALSE) {
677 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'custom_field', $prefix, []);
682 * Returns the list of fields that can be exported
684 * @param bool $prefix
688 public static function &export($prefix = FALSE) {
689 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'custom_field', $prefix, []);
694 * Returns the list of indices
696 * @param bool $localize
700 public static function indices($localize = TRUE) {
702 'UI_label_custom_group_id' => [
703 'name' => 'UI_label_custom_group_id',
706 1 => 'custom_group_id',
708 'localizable' => TRUE,
710 'sig' => 'civicrm_custom_field::1::label::custom_group_id',
712 'UI_name_custom_group_id' => [
713 'name' => 'UI_name_custom_group_id',
716 1 => 'custom_group_id',
718 'localizable' => FALSE,
720 'sig' => 'civicrm_custom_field::1::name::custom_group_id',
723 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;