Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LinkWidget.php

function LinkWidget::validateTitleNoLink

Form element validation handler for the 'title' element.

Requires the URL value if a link title was filled in.

File

core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php, line 172

Class

LinkWidget
Plugin implementation of the 'link' widget.

Namespace

Drupal\link\Plugin\Field\FieldWidget

Code

public static function validateTitleNoLink(&$element, FormStateInterface $form_state, $form) {
    if ($element['uri']['#value'] === '' && $element['title']['#value'] !== '') {
        $form_state->setError($element['uri'], new TranslatableMarkup('The @uri field is required when the @title field is specified.', [
            '@title' => $element['title']['#title'],
            '@uri' => $element['uri']['#title'],
        ]));
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal