Problem/Motivation

#2406749: Use a link field for custom menu link copied code from shortcut which got in in #2235457: Use link field for shortcut entity

so it looks like you can set a default value and max_length for the form.
But those have no effect.

Proposed resolution

-> take them out

(OR make them work)

Remaining tasks

User interface changes

API changes

CommentFileSizeAuthor
#3 2417809.3.patch1.29 KByesct

Comments

yesct’s picture

from #2406749: Use a link field for custom menu link it added in

MenuLinkContent

+    $fields['link'] = BaseFieldDefinition::create('link')
+      ->setLabel(t('Link'))
+      ->setDescription(t('The location this menu link points to.'))
+      ->setRequired(TRUE)
+      ->setSettings(array(
+        'default_value' => '',
+        'max_length' => 560,
+        'link_type' => LinkItemInterface::LINK_GENERIC,
+        'title' => DRUPAL_DISABLED,
+      ))
+    ;

but in

LinkItem

  public static function defaultFieldSettings() {
    return array(
      'title' => DRUPAL_OPTIONAL,
      'link_type' => LinkItemInterface::LINK_GENERIC
    ) + parent::defaultFieldSettings();
  }

expects title, link_type but not default_value or max_length

(FieldItemBase, the parent returns empty array)

  public static function defaultFieldSettings() {
    return array();
  }

grepping (ag):

$ ag "'max_length' => 560,"
core/modules/menu_link_content/src/Entity/MenuLinkContent.php
290:        'max_length' => 560,

core/modules/shortcut/src/Entity/Shortcut.php
155:        'max_length' => 560,

gives a clue that this code was copied from Shortcut

yesct’s picture

Issue summary: View changes
yesct’s picture

Status: Active » Needs review
StatusFileSize
new1.29 KB
yched’s picture

Status: Needs review » Reviewed & tested by the community

Sounds correct :-)

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Yay, less code!

Committed and pushed to 8.0.x. Thanks!

jibran’s picture

Status: Fixed » Reviewed & tested by the community

Not pushed yet.

webchick’s picture

Status: Reviewed & tested by the community » Fixed
jibran’s picture

Status: Fixed » Reviewed & tested by the community

Still nothing.

  • webchick committed ffdeb4b on 8.0.x
    Issue #2417809 by YesCT: link and shortcut have baseFieldDefinition...
webchick’s picture

Status: Reviewed & tested by the community » Fixed
(ノಠ益ಠ)ノ彡┻━┻
jibran’s picture

Thank you @webchick for your availability and awesome support during this sprint.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.