function ContentModerationStateForm::buildConfigurationForm

Same name and namespace in other branches
  1. 11.x core/modules/content_moderation/src/Form/ContentModerationStateForm.php \Drupal\content_moderation\Form\ContentModerationStateForm::buildConfigurationForm()
  2. 10 core/modules/content_moderation/src/Form/ContentModerationStateForm.php \Drupal\content_moderation\Form\ContentModerationStateForm::buildConfigurationForm()
  3. 8.9.x core/modules/content_moderation/src/Form/ContentModerationStateForm.php \Drupal\content_moderation\Form\ContentModerationStateForm::buildConfigurationForm()

File

core/modules/content_moderation/src/Form/ContentModerationStateForm.php, line 19

Class

ContentModerationStateForm
The content moderation state form.

Namespace

Drupal\content_moderation\Form

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state, StateInterface $state = NULL) {
  /** @var \Drupal\content_moderation\ContentModerationState $state */
  $state = $form_state->get('state');
  $is_required_state = isset($state) ? in_array($state->id(), $this->workflowType
    ->getRequiredStates(), TRUE) : FALSE;
  $form = [];
  $form['published'] = [
    '#type' => 'checkbox',
    '#title' => $this->t('Published'),
    '#description' => $this->t('When content reaches this state it should be published.'),
    '#default_value' => isset($state) ? $state->isPublishedState() : FALSE,
    '#disabled' => $is_required_state,
  ];
  $form['default_revision'] = [
    '#type' => 'checkbox',
    '#title' => $this->t('Default revision'),
    '#description' => $this->t('When content reaches this state it should be made the default revision; this is implied for published states.'),
    '#default_value' => isset($state) ? $state->isDefaultRevisionState() : FALSE,
    '#disabled' => $is_required_state,
  ];
  return $form;
}

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