flexiform-8.x-1.x-dev/contrib/wizard/src/Form/WizardForm.php
contrib/wizard/src/Form/WizardForm.php
<?php
namespace Drupal\flexiform_wizard\Form;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
/**
* Form to configure flexiform wizards.
*/
class WizardForm extends EntityForm {
/**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
$entity = $this->entity;
$form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Wizard Name'),
'#default_value' => $entity->label(),
'#size' => 30,
'#required' => TRUE,
'#maxlength' => 64,
'#description' => $this->t('The name of this wizard.'),
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $entity->id(),
'#required' => TRUE,
'#disabled' => !$entity->isNew(),
'#size' => 30,
'#maxlength' => 64,
'#machine_name' => [
'exists' => ['\Drupal\flexiform_wizard\Entity\Wizard', 'load'],
],
];
$form['path'] = [
'#type' => 'textfield',
'#title' => $this->t('Path'),
'#default_value' => $entity->get('path'),
'#required' => TRUE,
'#description' => $this->t('The path the wizard should reside at.'),
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$form_state->setRedirect('entity.flexiform_wizard.edit_form', ['flexiform_wizard' => $this->entity->id()]);
}
}
