function WorkflowStateDeleteForm::buildForm

Same name and namespace in other branches
  1. 9 core/modules/workflows/src/Form/WorkflowStateDeleteForm.php \Drupal\workflows\Form\WorkflowStateDeleteForm::buildForm()
  2. 8.9.x core/modules/workflows/src/Form/WorkflowStateDeleteForm.php \Drupal\workflows\Form\WorkflowStateDeleteForm::buildForm()
  3. 10 core/modules/workflows/src/Form/WorkflowStateDeleteForm.php \Drupal\workflows\Form\WorkflowStateDeleteForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

\Drupal\workflows\WorkflowInterface $workflow: The workflow entity being edited.

string|null $workflow_state: The workflow state being deleted.

Return value

array The form structure.

Overrides ConfirmFormBase::buildForm

File

core/modules/workflows/src/Form/WorkflowStateDeleteForm.php, line 74

Class

WorkflowStateDeleteForm
Builds the form to delete states from Workflow entities.

Namespace

Drupal\workflows\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, ?WorkflowInterface $workflow = NULL, $workflow_state = NULL) {
    if (!$workflow->getTypePlugin()
        ->hasState($workflow_state)) {
        throw new NotFoundHttpException();
    }
    $this->workflow = $workflow;
    $this->stateId = $workflow_state;
    if ($this->workflow
        ->getTypePlugin()
        ->workflowStateHasData($this->workflow, $this->workflow
        ->getTypePlugin()
        ->getState($this->stateId))) {
        $form['#title'] = $this->getQuestion();
        $form['description'] = [
            '#markup' => $this->t('This workflow state is in use. You cannot remove this workflow state until you have removed all content using it.'),
        ];
        return $form;
    }
    return parent::buildForm($form, $form_state);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.