+ /**
+ * Form element validation handler for the 'title' element.
+ *
+ * Requires the URL value if a link title was filled in.
+ */
+ public static function validateTitleNoLink(&$element, FormStateInterface $form_state, $form) {
+ if ($element['uri']['#value'] === '' && $element['title']['#value'] !== '') {
+ $form_state->setError($element['uri'], t('The @uri field is required when the @title field is specified.', ['@title' => $element['title']['#title'], '@uri' => $element['uri']['#title']]));
+ }
+ }
+