function FormTestControllerObject::buildForm

Same name and namespace in other branches
  1. 8.9.x core/modules/system/tests/modules/form_test/src/FormTestControllerObject.php \Drupal\form_test\FormTestControllerObject::buildForm()
  2. 10 core/modules/system/tests/modules/form_test/src/FormTestControllerObject.php \Drupal\form_test\FormTestControllerObject::buildForm()
  3. 11.x core/modules/system/tests/modules/form_test/src/FormTestControllerObject.php \Drupal\form_test\FormTestControllerObject::buildForm()

Overrides ConfigFormBase::buildForm

File

core/modules/system/tests/modules/form_test/src/FormTestControllerObject.php, line 44

Class

FormTestControllerObject
Provides a test form object.

Namespace

Drupal\form_test

Code

public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL, $custom_attributes = NULL) {
    $form['element'] = [
        '#markup' => 'The FormTestControllerObject::buildForm() method was used for this form.',
    ];
    $form['custom_attribute']['#markup'] = $custom_attributes;
    $form['request_attribute']['#markup'] = $request->attributes
        ->get('request_attribute');
    $form['bananas'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Bananas'),
    ];
    $form['actions']['#type'] = 'actions';
    $form['actions']['submit'] = [
        '#type' => 'submit',
        '#value' => $this->t('Save'),
    ];
    return $form;
}

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