You are here

public function NodeField::validateConfigurationForm in Entity Field Condition 8

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides ConditionPluginBase::validateConfigurationForm

File

src/Plugin/Condition/NodeField.php, line 233

Class

NodeField
Provides a 'Node Field' condition.

Namespace

Drupal\entity_field_condition\Plugin\Condition

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {

  // Get fields values.
  $entity_bundle = $form_state
    ->getValue('entity_bundle');
  $field = $form_state
    ->getValue('field');

  // Check validation.
  if ($entity_bundle && empty($field)) {
    $form_state
      ->setErrorByName('field', $this
      ->t('If you select a node type, you must specify a field.'));
  }
}