function LinkWidget::validateTitleNoLink
Same name in other branches
- 8.9.x core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php \Drupal\link\Plugin\Field\FieldWidget\LinkWidget::validateTitleNoLink()
- 10 core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php \Drupal\link\Plugin\Field\FieldWidget\LinkWidget::validateTitleNoLink()
- 11.x core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php \Drupal\link\Plugin\Field\FieldWidget\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 174
Class
- LinkWidget
- Plugin implementation of the 'link' widget.
Namespace
Drupal\link\Plugin\Field\FieldWidgetCode
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'],
]));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.