function TextForm::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/
theming_example/ src/ Form/ TextForm.php, line 26  
Class
- TextForm
 - A simple form that displays a textfield and submit button.
 
Namespace
Drupal\theming_example\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
  $form['text'] = [
    '#type' => 'textfield',
    '#title' => $this->t('Please input something!'),
    '#required' => TRUE,
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this->t('Go'),
  ];
  return $form;
}