Missing validateTitleElement method causes warnings and title fails to update

Created on 27 June 2022, over 2 years ago
Updated 23 February 2023, almost 2 years ago

Problem/Motivation

When saving is new node that has a link field with the linkit_field widget, you get a PHP warning when the title field of the link field is required.

Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Drupal\linkit_field\Plugin\Field\FieldWidget\LinkitWidget' does not have a method 'validateTitleElement' in Drupal\Core\Form\FormValidator->doValidateForm() (line 282 of core/lib/Drupal/Core/Form/FormValidator.php).

Steps to reproduce

  1. Add a link field to a content type
  2. Set the "Allow link text" option to "Required"
  3. Modify the form display and set the widget of the link field to Linkit and select a linkit profile
  4. Go to "Content" -> "Add content" -> and then the content type with the link field
  5. Fill in the required forms, but leave the link field empty
  6. Save the new node
  7. The PHP warnings will appear.

Proposed resolution

It seems like the validateTitleElement method is missing. We can copy it from the default LinkWidget and implement it in the LinkitWidget.

🐛 Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

🇳🇱Netherlands BryanDeNijs

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024