You are here

public function BooleanItemProcessor::buildConfigurationForm in Facets 8

Adds a configuration form for this processor.

Parameters

array $form: The form.

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

\Drupal\facets\FacetInterface $facet: The facet this processor is being added to.

Overrides ProcessorPluginBase::buildConfigurationForm

File

src/Plugin/facets/processor/BooleanItemProcessor.php, line 54

Class

BooleanItemProcessor
Provides a processor for boolean labels.

Namespace

Drupal\facets\Plugin\facets\processor

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state, FacetInterface $facet) {
  $config = $this
    ->getConfiguration();
  $build['on_value'] = [
    '#title' => $this
      ->t('On value'),
    '#type' => 'textfield',
    '#default_value' => $config['on_value'],
    '#description' => $this
      ->t('Use this label instead of <em>0</em> for the <em>On</em> or <em>True</em> value. Leave empty to hide this item.'),
    '#states' => [
      'required' => [
        'input[name="facet_settings[boolean_item][settings][off_value]"' => [
          'empty' => TRUE,
        ],
      ],
    ],
  ];
  $build['off_value'] = [
    '#title' => $this
      ->t('Off value'),
    '#type' => 'textfield',
    '#default_value' => $config['off_value'],
    '#description' => $this
      ->t('Use this label instead of <em>1</em> for the <em>Off</em> or <em>False</em> value. Leave empty to hide this item.'),
    '#states' => [
      'required' => [
        'input[name="facet_settings[boolean_item][settings][on_value]"' => [
          'empty' => TRUE,
        ],
      ],
    ],
  ];
  return $build;
}