function WorkflowStateAddForm::form
Same name in other branches
- 8.9.x core/modules/workflows/src/Form/WorkflowStateAddForm.php \Drupal\workflows\Form\WorkflowStateAddForm::form()
- 10 core/modules/workflows/src/Form/WorkflowStateAddForm.php \Drupal\workflows\Form\WorkflowStateAddForm::form()
- 11.x core/modules/workflows/src/Form/WorkflowStateAddForm.php \Drupal\workflows\Form\WorkflowStateAddForm::form()
Overrides EntityForm::form
File
-
core/
modules/ workflows/ src/ Form/ WorkflowStateAddForm.php, line 56
Class
- WorkflowStateAddForm
- Entity form variant for adding workflow states.
Namespace
Drupal\workflows\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/** @var \Drupal\workflows\WorkflowInterface $workflow */
$workflow = $this->getEntity();
$workflow_type = $workflow->getTypePlugin();
$form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('State label'),
'#maxlength' => 255,
'#default_value' => '',
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#machine_name' => [
'exists' => [
$this,
'exists',
],
],
];
if ($workflow_type->hasFormClass(StateInterface::PLUGIN_FORM_KEY)) {
$form['type_settings'] = [
'#tree' => TRUE,
];
$subform_state = SubformState::createForSubform($form['type_settings'], $form, $form_state);
$form['type_settings'] += $this->pluginFormFactory
->createInstance($workflow_type, StateInterface::PLUGIN_FORM_KEY)
->buildConfigurationForm($form['type_settings'], $subform_state);
}
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.