You are here

public function OneForm::buildForm in Chaos Tool Suite (ctools) 8.3

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;
}