contact_entity_extra_field_info

contact_entity_extra_field_info()

Implements hook_entity_extra_field_info().

File

core/modules/contact/contact.module, line 52
Enables the use of personal and site-wide contact forms.

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function contact_entity_extra_field_info() {
  $fields = array();
  foreach (array_keys(\Drupal::service('entity_type.bundle.info')->getBundleInfo('contact_message')) as $bundle) {
    $fields['contact_message'][$bundle]['form']['name'] = array(
      'label' => t('Sender name'),
      'description' => t('Text'),
      'weight' => -50,
    );
    $fields['contact_message'][$bundle]['form']['mail'] = array(
      'label' => t('Sender email'),
      'description' => t('Email'),
      'weight' => -40,
    );
    if ($bundle == 'personal') {
      $fields['contact_message'][$bundle]['form']['recipient'] = array(
        'label' => t('Recipient username'),
        'description' => t('User'),
        'weight' => -30,
      );
    }
    $fields['contact_message'][$bundle]['form']['copy'] = array(
      'label' => t('Send copy to sender'),
      'description' => t('Option'),
      'weight' => 50,
    );
  }
 
  $fields['user']['user']['form']['contact'] = array(
    'label' => t('Contact settings'),
    'description' => t('Contact module form element.'),
    'weight' => 5,
  );
  return $fields;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.