Skip to content
Snippets Groups Projects
Verified Commit ac20b4fd authored by Julian Pustkuchen's avatar Julian Pustkuchen Committed by Lee Rowlands
Browse files

Issue #3191538 by Grevil, Anybody, Anjali Rathod, sudiptadas19, himerus,...

Issue #3191538 by Grevil, Anybody, Anjali Rathod, sudiptadas19, himerus, larowlan: Hide attributes details if none are enabled
parent bfe6b930
No related branches found
Tags 8.x-1.14
No related merge requests found
......@@ -92,6 +92,12 @@ class LinkWithAttributesWidget extends LinkWidget implements ContainerFactoryPlu
$options = $item->get('options')->getValue();
$attributes = $options['attributes'] ?? [];
// Condition to check if there are any enabled attributes, if not, an
// empty element is returned:
if (empty(array_filter($this->getSetting('enabled_attributes')))) {
return $element;
}
$element['options']['attributes'] = [
'#type' => 'details',
'#title' => $this->t('Attributes'),
......
......@@ -173,6 +173,10 @@ class LinkAttributesFieldTest extends BrowserTestBase {
$web_assert = $this->assertSession();
// Link attributes.
$web_assert->elementExists('css', '.field--widget-link-attributes');
// The "Attributes" details form should not be present, since no attributes
// are enabled:
$web_assert->elementNotExists('css', 'edit-field-' . $field_name . '-0-options-attributes');
// Create a node.
$edit = [
'title[0][value]' => 'A multi field link test',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment