ExampleConfigEntityOneForm.php in Chaos Tool Suite (ctools) 8.3
File
tests/modules/ctools_wizard_test/src/Form/ExampleConfigEntityOneForm.php
View source
<?php
namespace Drupal\ctools_wizard_test\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class ExampleConfigEntityOneForm extends FormBase {
public function getFormId() {
return 'ctools_wizard_test_config_entity_one_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$cached_values = $form_state
->getTemporaryValue('wizard');
$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;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$cached_values = $form_state
->getTemporaryValue('wizard');
$config_entity = $cached_values['ctools_wizard_test_config_entity'];
$config_entity
->set('one', $form_state
->getValue('one'));
}
}