You are here

public function NextPreviousBlock::blockForm in Next Previous Post Block (Node or Page Pagination) 1.0.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/Block/NextPreviousBlock.php \Drupal\nextpre\Plugin\Block\NextPreviousBlock::blockForm()
  2. 8 src/Plugin/Block/NextPreviousBlock.php \Drupal\nextpre\Plugin\Block\NextPreviousBlock::blockForm()
  3. 9.0.x src/Plugin/Block/NextPreviousBlock.php \Drupal\nextpre\Plugin\Block\NextPreviousBlock::blockForm()

Returns the configuration form elements specific to this block plugin.

Blocks that need to add form elements to the normal block configuration form should implement this method.

Parameters

array $form: The form definition array for the block configuration form.

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

Return value

array The renderable form array representing the entire configuration form.

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/NextPreviousBlock.php, line 78

Class

NextPreviousBlock
Provides a 'Next Previous' block.

Namespace

Drupal\nextpre\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $node_types = node_type_get_names();
  $form['content_type'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Content Types'),
    '#empty_option' => $this
      ->t('-None-'),
    '#options' => $node_types,
    '#default_value' => isset($this->configuration['content_type']) ? $this->configuration['content_type'] : '',
    '#required' => TRUE,
  ];
  $form['previous_text'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Previous text'),
    '#description' => $this
      ->t('Add your previous button name'),
    '#default_value' => isset($this->configuration['previous_text']) ? $this->configuration['previous_text'] : '',
    '#required' => TRUE,
  ];
  $form['next_text'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Next text'),
    '#description' => $this
      ->t('Add your next button name'),
    '#default_value' => isset($this->configuration['next_text']) ? $this->configuration['next_text'] : '',
    '#required' => TRUE,
  ];
  $form['previouslink_class'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Previous link class'),
    '#description' => $this
      ->t('Add your class in previous link'),
    '#default_value' => isset($this->configuration['previouslink_class']) ? $this->configuration['previouslink_class'] : '',
  ];
  $form['nextlink_class'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Next link class'),
    '#description' => $this
      ->t('Add your class in next link'),
    '#default_value' => isset($this->configuration['nextlink_class']) ? $this->configuration['nextlink_class'] : '',
  ];
  return $form;
}