function FormTestArgumentsObject::buildForm

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

Overrides ConfigFormBase::buildForm

File

core/modules/system/tests/modules/form_test/src/FormTestArgumentsObject.php, line 34

Class

FormTestArgumentsObject
Provides a test form object that needs arguments.

Namespace

Drupal\form_test

Code

public function buildForm(array $form, FormStateInterface $form_state, $arg = NULL) {
    $form['element'] = [
        '#markup' => 'The FormTestArgumentsObject::buildForm() method was used for this form.',
    ];
    $form['bananas'] = [
        '#type' => 'textfield',
        '#default_value' => $arg,
        '#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.