function TwoForm::buildForm

Same name and namespace in other branches
  1. 4.0.x tests/modules/ctools_wizard_test/src/Form/TwoForm.php \Drupal\ctools_wizard_test\Form\TwoForm::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

tests/modules/ctools_wizard_test/src/Form/TwoForm.php, line 34

Class

TwoForm
Simple wizard step form.

Namespace

Drupal\ctools_wizard_test\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $cached_values = $form_state->getTemporaryValue('wizard');
    $form['two'] = [
        '#title' => $this->t('Two'),
        '#type' => 'textfield',
        '#default_value' => !empty($cached_values['two']) ? $cached_values['two'] : '',
    ];
    $form['dynamic'] = [
        '#title' => $this->t('Dynamic value'),
        '#type' => 'item',
        '#markup' => !empty($cached_values['dynamic']) ? $cached_values['dynamic'] : '',
    ];
    return $form;
}