Skip to content

CRM Method Detail Type Entity

Overview

The crm_method_detail_type entity provides semantic classification for contact methods, allowing you to specify the context or purpose of each contact method detail (e.g., "home" vs "work" email, "mobile" vs "fax" telephone).

Key Features

  • Configuration Entity: Lightweight, exportable configuration entity
  • Bundle Filtering: Can be restricted to specific contact method bundles (address, email, telephone)
  • Negate Logic: Supports inclusive and exclusive bundle restrictions
  • Status Management: Can be enabled or disabled
  • Flexible Classification: Allows unlimited custom types to be created

Entity Purpose

Method detail types provide a secondary classification layer for contact methods. While the contact method bundle determines what kind of data is stored (address, email, or telephone), the method detail type provides context about how that data is used:

  • Global Types (all bundles): home, work, main, other
  • Telephone-Specific: mobile, fax, voicemail
  • Address-Specific: billing

Relationship to Contact Methods

Every crm_contact_method entity can reference a method detail type through its type field. The available types are automatically filtered based on the contact method's bundle, using the bundle filtering logic configured in each method detail type.

Entity Structure

classDiagram
  class crm_method_detail_type {
    +string id [PK]
    +string label
    +string description
    +array bundles
    +bool negate
    +bool status
  }

  class crm_contact_method {
    +int id [PK]
    +string bundle
    +int type --> crm_method_detail_type.id
    +int crm_contact
  }

  class crm_contact_method_type {
    +string id [PK]
    +string label
  }

  %% Relationships
  crm_contact_method }o--|| crm_method_detail_type : "classified by"
  crm_contact_method }o--|| crm_contact_method_type : "bundle type"

  %% Notes on filtering
  note for crm_method_detail_type "Bundle Filtering Logic:\n- Empty bundles[] = applies to all\n- negate=false: applies to listed bundles\n- negate=true: applies to all EXCEPT listed"

Properties Reference

Property Type Required Description
id String Yes Machine name identifier (e.g., "home", "work", "mobile")
label String Yes Human-readable label displayed in forms and views
description Text No Optional description of the type's purpose
bundles Array No Array of contact method bundle IDs this type applies to
negate Boolean No If TRUE, applies to all bundles EXCEPT those listed
status Boolean No Whether the type is enabled (default: TRUE)

Configuration Reference

Default Method Detail Types

The following method detail types are provided by default:

Type ID Label Description Applicable Bundles Negate
home Home Personal/home contact information All (empty array) false
work Work Business/work contact information All (empty array) false
main Main Primary contact information All (empty array) false
other Other Alternative contact information All (empty array) false
mobile Mobile Mobile telephone number telephone only false
fax Fax Fax telephone number telephone only false
voicemail Voicemail Voicemail telephone number telephone only false
billing Billing Billing address address only false

Bundle Filtering Logic

The bundles array and negate flag work together to control which contact method bundles can use each method detail type:

Case 1: Empty Bundles Array (Global Types)

When bundles is an empty array, the type applies to all contact method bundles regardless of the negate value.

id: home
label: Home
bundles: []
negate: false  # Ignored when bundles is empty

Result: Available for address, email, and telephone bundles.

Case 2: Inclusive Bundle Filtering (negate = false)

When bundles contains values and negate is false, the type applies only to the listed bundles.

id: mobile
label: Mobile
bundles:
  - telephone
negate: false

Result: Available only for telephone bundle contact methods.

Case 3: Exclusive Bundle Filtering (negate = true)

When bundles contains values and negate is true, the type applies to all bundles except those listed.

id: non_telephone
label: Non-Telephone
bundles:
  - telephone
negate: true

Result: Available for address and email bundles, but not telephone.

Configuration File Examples

Method detail types are stored as configuration entities in YAML files:

Global Type Example

# config/install/crm.crm_method_detail_type.home.yml
langcode: en
status: true
dependencies: {}
id: home
label: Home
description: ''
bundles: []
negate: false

Bundle-Specific Type Example

# config/install/crm.crm_method_detail_type.mobile.yml
langcode: en
status: true
dependencies: {}
id: mobile
label: Mobile
description: ''
bundles:
  - telephone
negate: false

Address-Only Type Example

# config/install/crm.crm_method_detail_type.billing.yml
langcode: en
status: true
dependencies: {}
id: billing
label: Billing
description: ''
bundles:
  - address
negate: false

Selection Plugin

The MethodDetailTypeSelection plugin automatically filters available method detail types based on the contact method's bundle. This ensures users only see relevant type options when creating or editing contact methods.

Plugin ID: default:crm_method_detail_type

Filtering Logic: 1. Only shows enabled types (status = TRUE) 2. Checks bundle compatibility using the logic described above 3. Applies during entity reference field autocomplete and select lists

Administrative Interface

Admin URLs

Page URL Description
Collection /admin/structure/crm/method-detail-type List all method detail types
Add Form /admin/structure/crm/method-detail-type/add Create a new method detail type
Edit Form /admin/structure/crm/method-detail-type/manage/{id} Edit an existing method detail type
Delete Form /admin/structure/crm/method-detail-type/manage/{id}/delete Delete a method detail type

Required Permissions

All method detail type operations require the administer crm permission.

Form Fields

The method detail type form includes the following fields:

Label

  • Field Type: Text field
  • Required: Yes
  • Description: Human-readable name displayed to users
  • Example: "Home", "Work", "Mobile"

Machine Name (ID)

  • Field Type: Machine name
  • Required: Yes
  • Editable: Only when creating new types
  • Generated From: Label field
  • Example: "home", "work", "mobile"

Enabled

  • Field Type: Checkbox
  • Required: No
  • Default: Checked
  • Description: Disabled types are not available for selection but existing references remain intact

Description

  • Field Type: Textarea
  • Required: No
  • Description: Optional text to explain the type's purpose

Bundles

  • Field Type: Checkboxes
  • Options: Dynamically loaded from crm_contact_method_type entities
  • Address
  • Email
  • Telephone
  • Description: Select which contact method bundles this type applies to
  • Note: Leave empty for global types that apply to all bundles

Negate

  • Field Type: Checkbox
  • Required: No
  • Default: Unchecked (false)
  • Description: If checked, this type applies to all bundles except those selected above

Form Handler

The MethodDetailTypeForm class handles form building and submission:

Location: src/Form/MethodDetailTypeForm.php

Key Features: - Validates machine name uniqueness - Filters empty checkbox values from bundles array - Provides contextual help text when no contact method types exist - Redirects to collection page after save

Usage Examples

Creating Custom Method Detail Types

Example 1: Emergency Contact (Phone Only)

Create a method detail type for emergency contact phone numbers:

id: emergency
label: Emergency
description: 'Emergency contact telephone number'
bundles:
  - telephone
negate: false

Example 2: Shipping Address (Address Only)

Create a method detail type specifically for shipping addresses:

id: shipping
label: Shipping
description: 'Address for shipping deliveries'
bundles:
  - address
negate: false

Example 3: Personal (Email and Phone Only)

Create a type for personal contact methods, excluding addresses:

id: personal
label: Personal
description: 'Personal email or phone'
bundles:
  - address
negate: true

This configuration would make "Personal" available for email and telephone bundles, but not for addresses.

Integration with Contact Methods

When creating or editing a contact method, the type field automatically filters available options based on:

  1. The contact method's bundle (address, email, or telephone)
  2. Each method detail type's bundles and negate configuration
  3. The method detail type's status (enabled/disabled)

Example Workflow

  1. User creates a new telephone contact method
  2. System checks all method detail types:
  3. "home" (empty bundles) ✓ Available
  4. "work" (empty bundles) ✓ Available
  5. "mobile" (bundles: [telephone]) ✓ Available
  6. "billing" (bundles: [address]) ✗ Not available
  7. User sees filtered dropdown with only: home, work, main, other, mobile, fax, voicemail

Best Practices

Naming Conventions

  • Use lowercase machine names with underscores: emergency_contact, not Emergency-Contact
  • Keep labels short and descriptive: "Emergency" not "Emergency Contact Number"
  • Use consistent terminology across your organization

Bundle Configuration

  • Leave bundles empty for types that apply universally (home, work, other)
  • Use specific bundles for context-specific types (mobile for telephone, billing for address)
  • Avoid over-segmentation: Don't create bundle-specific versions of generic types

Negate Flag Usage

  • Use negate: true sparingly, as it can be confusing
  • Document the reasoning when using negate in configuration comments
  • Prefer explicit positive bundle lists over negation when possible

Status Management

  • Disable rather than delete types that are no longer needed
  • Disabled types preserve existing data while preventing new usage
  • Re-enable types if they become relevant again