You are here

function tvi_form_config_validate in Taxonomy Views Integrator 8

Validate that if override is enable, that we have values for the view.

Due to bugs in #states array, we can't have required fields that are hidden.

Parameters

array $form: Settings form render array.

\Drupal\Core\Form\FormStateInterface $form_state: Submitted form state.

1 string reference to 'tvi_form_config_validate'
_tvi_settings_form in ./tvi.module
Helper function to construct the forms for both term and vocab edit forms.

File

./tvi.module, line 173
Allow views to be used instead of default taxonomy term page behavior.

Code

function tvi_form_config_validate(array $form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  if ($values['tvi_enable_override']) {
    if (!mb_strlen($values['tvi_view'])) {
      $form_state
        ->setError($form['tvi']['tvi_view'], t('To override the term presentation, you must specify a view.'));
    }
    if (!mb_strlen($values['tvi_view_display'])) {
      $form_state
        ->setError($form['tvi']['tvi_view_display'], t('To override the term presentation, you must specify a view display.'));
    }
  }
}