diff --git a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php index 9c97caa..1bbd376 100644 --- a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php +++ b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php @@ -155,7 +155,6 @@ public static function validateUriElement($element, FormStateInterface $form_sta */ 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']))); @@ -225,6 +224,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // non-empty. Omit the validation on the field edit form, since the field // settings cannot be saved otherwise. if (!$this->isDefaultValueWidget($form_state) && $this->getFieldSetting('title') == DRUPAL_REQUIRED) { + $element['title']['#description'] = $this->t('The link text will be required if you insert an URL.'); $element['#element_validate'][] = array(get_called_class(), 'validateTitleElement'); }