You are here

public function KeyConfigOverrideAddForm::validateForm in Key 8

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

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

Overrides FormBase::validateForm

File

src/Form/KeyConfigOverrideAddForm.php, line 196

Class

KeyConfigOverrideAddForm
KeyConfigOverrideAddForm class.

Namespace

Drupal\key\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);

  // Add the entity prefix when the form is submitted.
  if ($form_state
    ->isSubmitted()) {
    $definitions = $this
      ->getConfigEntityTypeDefinitions();
    $config_type = $form_state
      ->getValue('config_type');
    if (array_key_exists($config_type, $definitions)) {
      $config_prefix = $definitions[$config_type]
        ->getConfigPrefix();
    }
    else {
      $config_prefix = '';
    }
    $form_state
      ->setValue('config_prefix', $config_prefix);
  }
}