function ExampleConfigEntityOneForm::buildForm

Same name and namespace in other branches
  1. 4.0.x tests/modules/ctools_wizard_test/src/Form/ExampleConfigEntityOneForm.php \Drupal\ctools_wizard_test\Form\ExampleConfigEntityOneForm::buildForm()

Overrides FormInterface::buildForm

File

tests/modules/ctools_wizard_test/src/Form/ExampleConfigEntityOneForm.php, line 24

Class

ExampleConfigEntityOneForm
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');
    
    /** @var \Drupal\ctools_wizard_test\Entity\ExampleConfigEntity $page */
    $config_entity = $cached_values['ctools_wizard_test_config_entity'];
    $form['one'] = [
        '#title' => $this->t('One'),
        '#type' => 'textfield',
        '#default_value' => $config_entity->getOne() ?: '',
    ];
    $form['external'] = [
        '#type' => 'link',
        '#title' => $this->t('Show on dialog'),
        '#url' => new Url('entity.ctools_wizard_test_config_entity.external_form', [
            'machine_name' => $config_entity->id(),
        ]),
        '#attributes' => [
            'class' => 'use-ajax',
            'data-dialog-type' => 'modal',
        ],
    ];
    return $form;
}