3 namespace Drupal\ctools_wizard_test\Form;
6 use Drupal\Core\Form\FormBase;
7 use Drupal\Core\Form\FormStateInterface;
10 * Simple wizard step form.
12 class OneForm extends FormBase {
15 * Returns a unique string identifying the form.
18 * The unique string identifying the form.
20 public function getFormId() {
21 return 'ctools_wizard_test_one_form';
28 * An associative array containing the structure of the form.
29 * @param \Drupal\Core\Form\FormStateInterface $form_state
30 * The current state of the form.
35 public function buildForm(array $form, FormStateInterface $form_state) {
36 $cached_values = $form_state->getTemporaryValue('wizard');
38 '#title' => $this->t('One'),
39 '#type' => 'textfield',
40 '#default_value' => !empty($cached_values['one']) ? $cached_values['one'] : '',
43 '#title' => $this->t('Dynamic value'),
45 '#markup' => !empty($cached_values['dynamic']) ? $cached_values['dynamic'] : '',
51 * Form submission handler.
54 * An associative array containing the structure of the form.
55 * @param \Drupal\Core\Form\FormStateInterface $form_state
56 * The current state of the form.
58 public function submitForm(array &$form, FormStateInterface $form_state) {
62 $cached_values = $form_state->getTemporaryValue('wizard');
63 foreach ($keys as $key) {
64 $cached_values[$key] = $form_state->getValue($key);
66 $form_state->setTemporaryValue('wizard', $cached_values);
68 drupal_set_message($this->t('Dynamic value submitted: @value', ['@value' => $cached_values['dynamic']]));;