You are here

public function PromoteDisableForm::buildForm in Promote Disable 8

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.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/PromoteDisableForm.php, line 66

Class

PromoteDisableForm
Class PromoteDisableForm.

Namespace

Drupal\promote_disable\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $node_types = $this
    ->promoteDisableNodeTypes();
  $form['promote_to_front_page'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Promote to front page'),
    '#open' => TRUE,
  ];
  $form['promote_to_front_page']['promote_disable_node_types'] = [
    '#type' => 'select',
    '#multiple' => TRUE,
    '#size' => count($node_types),
    '#title' => $this
      ->t('Content types'),
    '#default_value' => $this->config
      ->get('promote_disable_node_types'),
    '#options' => $node_types,
    '#description' => $this
      ->t('Select the content types on which you would like to disable the "Promoted to front page" option.'),
  ];
  $form['sticky'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Make content sticky'),
    '#open' => TRUE,
  ];
  $form['sticky']['promote_disable_sticky_node_types'] = [
    '#type' => 'select',
    '#multiple' => TRUE,
    '#size' => count($node_types),
    '#title' => $this
      ->t('Content types'),
    '#default_value' => $this->config
      ->get('promote_disable_sticky_node_types'),
    '#options' => $node_types,
    '#description' => $this
      ->t('Select the content types on which you would like to disable the "Sticky option.'),
  ];
  return parent::buildForm($form, $form_state);
}