function ContactStorageTestHooks::formContactFormFormAlter

Implements hook_form_FORM_ID_alter() for contact_form_form().

File

core/modules/contact/tests/modules/contact_storage_test/src/Hook/ContactStorageTestHooks.php, line 48

Class

ContactStorageTestHooks
Hook implementations for contact_storage_test.

Namespace

Drupal\contact_storage_test\Hook

Code

public function formContactFormFormAlter(&$form, FormStateInterface $form_state) : void {
    
    /** @var \Drupal\contact\ContactFormInterface $contact_form */
    $contact_form = $form_state->getFormObject()
        ->getEntity();
    $form['send_a_pony'] = [
        '#type' => 'checkbox',
        '#title' => 'Send submitters a voucher for a free pony.',
        '#description' => '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'][] = [
        $this,
        'contactFormBuilder',
    ];
}

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