You are here

public function FormTestServiceObject::buildForm in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/form_test/src/FormTestServiceObject.php \Drupal\form_test\FormTestServiceObject::buildForm()
  2. 10 core/modules/system/tests/modules/form_test/src/FormTestServiceObject.php \Drupal\form_test\FormTestServiceObject::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 ConfigFormBase::buildForm

File

core/modules/system/tests/modules/form_test/src/FormTestServiceObject.php, line 32

Class

FormTestServiceObject
Provides a test form object.

Namespace

Drupal\form_test

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['element'] = [
    '#markup' => 'The FormTestServiceObject::buildForm() method was used for this form.',
  ];
  $form['bananas'] = [
    '#type' => 'textfield',
    '#default_value' => 'brown',
    '#title' => $this
      ->t('Bananas'),
  ];
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Save'),
  ];
  return $form;
}