public function EmailExampleGetFormPage::buildForm in Examples for Developers 8
Same name and namespace in other branches
- 3.x modules/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
- email_example/
src/ Form/ EmailExampleGetFormPage.php, line 80
Class
- EmailExampleGetFormPage
- File test form class.
Namespace
Drupal\email_example\FormCode
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;
}