You are here

public function TaxonomyFacetsBlock1::blockForm in Taxonomy Facets 8

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/TaxonomyFacetsBlock1.php, line 45

Class

TaxonomyFacetsBlock1
Provides a 'Taxonomy Facets Menu' block.

Namespace

Drupal\taxonomy_facets\Plugin\Block

Code

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

  // Retrieve existing configuration for this block.
  $config = $this
    ->getConfiguration();
  $form['vocab_select'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Select vocabulary. This block will display filters based on the taxonomy terms from the selected vocabulary'),
    '#options' => taxonomy_vocabulary_get_names(),
    '#default_value' => isset($config['taxo_vocabulary_id']) ? $config['taxo_vocabulary_id'] : '',
  ];
  return $form;
}