public static function LinkWidget::validateTitleElement in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php \Drupal\link\Plugin\Field\FieldWidget\LinkWidget::validateTitleElement()
Form element validation handler for the 'title' element.
Conditionally requires the link title if a URL value was filled in.
File
- core/
modules/ link/ src/ Plugin/ Field/ FieldWidget/ LinkWidget.php, line 156 - Contains \Drupal\link\Plugin\Field\FieldWidget\LinkWidget.
Class
- LinkWidget
- Plugin implementation of the 'link' widget.
Namespace
Drupal\link\Plugin\Field\FieldWidgetCode
public static function validateTitleElement(&$element, FormStateInterface $form_state, $form) {
if ($element['uri']['#value'] !== '' && $element['title']['#value'] === '') {
$element['title']['#required'] = TRUE;
// We expect the field name placeholder value to be wrapped in t() here,
// so it won't be escaped again as it's already marked safe.
$form_state
->setError($element['title'], t('@name field is required.', array(
'@name' => $element['title']['#title'],
)));
}
}