You are here

function contact_storage_test_form_contact_form_form_alter in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module \contact_storage_test_form_contact_form_form_alter()
  2. 9 core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module \contact_storage_test_form_contact_form_form_alter()

Implements hook_form_FORM_ID_alter() for contact_form_form().

File

core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module, line 47
Contains custom contact message functionality for ContactStorageTest.

Code

function contact_storage_test_form_contact_form_form_alter(&$form, FormStateInterface $form_state) {

  /** @var \Drupal\contact\ContactFormInterface $contact_form */
  $contact_form = $form_state
    ->getFormObject()
    ->getEntity();
  $form['send_a_pony'] = [
    '#type' => 'checkbox',
    '#title' => t('Send submitters a voucher for a free pony.'),
    '#description' => t('Enable to send an additional email with a free pony voucher to anyone who submits the form.'),
    '#default_value' => $contact_form
      ->getThirdPartySetting('contact_storage_test', 'send_a_pony', FALSE),
  ];
  $form['#entity_builders'][] = 'contact_storage_test_contact_form_form_builder';
}