'#title' => $this->t('Label'),
'#maxlength' => 255,
'#default_value' => $workflow->label(),
- '#description' => $this->t('Label for the Workflow.'),
'#required' => TRUE,
];
],
];
- $workflow_types = array_map(function ($plugin_definition) {
- return $plugin_definition['label'];
- }, $this->workflowTypePluginManager->getDefinitions());
+ $workflow_types = array_column($this->workflowTypePluginManager->getDefinitions(), 'label', 'id');
+
$form['workflow_type'] = [
'#type' => 'select',
'#title' => $this->t('Workflow type'),
public function save(array $form, FormStateInterface $form_state) {
/* @var \Drupal\workflows\WorkflowInterface $workflow */
$workflow = $this->entity;
- // Initialize the workflow using the selected type plugin.
- $workflow = $workflow->getTypePlugin()->initializeWorkflow($workflow);
$return = $workflow->save();
- if (empty($workflow->getStates())) {
+ if (empty($workflow->getTypePlugin()->getStates())) {
drupal_set_message($this->t('Created the %label Workflow. In order for the workflow to be enabled there needs to be at least one state.', [
'%label' => $workflow->label(),
]));