function contact_entity_extra_field_info

Same name in other branches
  1. 9 core/modules/contact/contact.module \contact_entity_extra_field_info()
  2. 10 core/modules/contact/contact.module \contact_entity_extra_field_info()
  3. 11.x core/modules/contact/contact.module \contact_entity_extra_field_info()

Implements hook_entity_extra_field_info().

File

core/modules/contact/contact.module, line 54

Code

function contact_entity_extra_field_info() {
    $fields = [];
    foreach (array_keys(\Drupal::service('entity_type.bundle.info')->getBundleInfo('contact_message')) as $bundle) {
        $fields['contact_message'][$bundle]['form']['name'] = [
            'label' => t('Sender name'),
            'description' => t('Text'),
            'weight' => -50,
        ];
        $fields['contact_message'][$bundle]['form']['mail'] = [
            'label' => t('Sender email'),
            'description' => t('Email'),
            'weight' => -40,
        ];
        if ($bundle == 'personal') {
            $fields['contact_message'][$bundle]['form']['recipient'] = [
                'label' => t('Recipient username'),
                'description' => t('User'),
                'weight' => -30,
            ];
        }
        $fields['contact_message'][$bundle]['form']['preview'] = [
            'label' => t('Preview sender message'),
            'description' => t('Preview'),
            'weight' => 40,
        ];
        $fields['contact_message'][$bundle]['form']['copy'] = [
            'label' => t('Send copy to sender'),
            'description' => t('Option'),
            'weight' => 50,
        ];
    }
    $fields['user']['user']['form']['contact'] = [
        'label' => t('Contact settings'),
        'description' => t('Contact module form element.'),
        'weight' => 5,
    ];
    return $fields;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.