You are here

public function EmailExampleGetFormPage::buildForm in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 email_example/src/Form/EmailExampleGetFormPage.php \Drupal\email_example\Form\EmailExampleGetFormPage::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

modules/email_example/src/Form/EmailExampleGetFormPage.php, line 80

Class

EmailExampleGetFormPage
File test form class.

Namespace

Drupal\email_example\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['intro'] = [
    '#markup' => $this
      ->t('Use this form to send a message to an e-mail address. No spamming!'),
  ];
  $form['email'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('E-mail address'),
    '#required' => TRUE,
  ];
  $form['message'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Message'),
    '#required' => TRUE,
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Submit'),
  ];
  return $form;
}