function OneForm::buildForm

Same name in other branches
  1. 4.0.x tests/modules/ctools_wizard_test/src/Form/OneForm.php \Drupal\ctools_wizard_test\Form\OneForm::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/OneForm.php, line 34

Class

OneForm
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['one'] = [
        '#title' => $this->t('One'),
        '#type' => 'textfield',
        '#default_value' => !empty($cached_values['one']) ? $cached_values['one'] : '',
    ];
    $form['dynamic'] = [
        '#title' => $this->t('Dynamic value'),
        '#type' => 'item',
        '#markup' => !empty($cached_values['dynamic']) ? $cached_values['dynamic'] : '',
    ];
    return $form;
}