You are here

public function LinkitDrupalLink::validateLinkitProfileSelection in Linkit 8.5

Linkit profile select validation.

#element_validate callback for the "linkit_profile" element.

Parameters

array $element: An associative array containing the properties and children of the generic form element.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form for the form this element belongs to.

See also

\Drupal\Core\Render\Element\FormElement::processPattern()

File

src/Plugin/CKEditorPlugin/LinkitDrupalLink.php, line 98

Class

LinkitDrupalLink
Adds a settings form to select a Linkit profile on the default link plugin.

Namespace

Drupal\linkit\Plugin\CKEditorPlugin

Code

public function validateLinkitProfileSelection(array $element, FormStateInterface $form_state) {
  $values = $form_state
    ->getValue([
    'editor',
    'settings',
    'plugins',
    'drupallink',
  ]);
  $enabled = isset($values['linkit_enabled']) && $values['linkit_enabled'] === 1;
  if ($enabled && empty(trim($values['linkit_profile']))) {
    $form_state
      ->setError($element, $this
      ->t('Please select the Linkit profile you wish to use.'));
  }
}