Hide attributes details if none are enabled.

Created on 7 January 2021, almost 4 years ago
Updated 22 June 2023, over 1 year ago

Problem/Motivation

I'm using this module specifically for two custom attributes that get preprocessed and passed as attributes on a web component. Not using any of the default attributes.

They are all set to default by default, and are intended only for custom link fields attached to nodes/blocks/etc.
However, I now have an empty attributes details item on default menu links as pictured in the attached screenshot.

Steps to reproduce

$fields['link']->setDisplayOptions('form', [
      'type' => 'link_attributes',
      'weight' => -2,
      'settings' => [
        'enabled_attributes' => [
          'id' => FALSE,
          'name' => FALSE,
          'target' => FALSE,
          'rel' => FALSE,
          'class' => FALSE,
          'accesskey' => FALSE,
          // Add your own custom attributes as required.
          'data-variant' => FALSE,
          'data-arrow' => FALSE,
        ],
      ],
    ]);

Proposed resolution

  $element['options']['attributes'] = [
      '#type' => 'details',
      '#title' => $this->t('Attributes'),
      '#tree' => TRUE,
      '#open' => count($attributes),
    ];

in LinkWithAttributesWidget.php should be hidden entirely if there aren't any available attributes to be configured for a link.

✨ Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States himerus

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