You are here

public function ModerationStateForm::form in Workbench Moderation 8.2

Same name and namespace in other branches
  1. 8 src/Form/ModerationStateForm.php \Drupal\workbench_moderation\Form\ModerationStateForm::form()

Gets the actual form array to be built.

Overrides EntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

src/Form/ModerationStateForm.php, line 17

Class

ModerationStateForm
Class ModerationStateForm.

Namespace

Drupal\workbench_moderation\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);

  /* @var \Drupal\workbench_moderation\ModerationStateInterface $moderation_state */
  $moderation_state = $this->entity;
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $moderation_state
      ->label(),
    '#description' => $this
      ->t("Label for the Moderation state."),
    '#required' => TRUE,
  );
  $form['id'] = array(
    '#type' => 'machine_name',
    '#default_value' => $moderation_state
      ->id(),
    '#machine_name' => array(
      'exists' => '\\Drupal\\workbench_moderation\\Entity\\ModerationState::load',
    ),
    '#disabled' => !$moderation_state
      ->isNew(),
  );
  $form['published'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Published'),
    '#description' => $this
      ->t('When content reaches this state it should be published.'),
    '#default_value' => $moderation_state
      ->isPublishedState(),
  ];
  $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' => $moderation_state
      ->isDefaultRevisionState(),
  ];
  return $form;
}