Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
menu_link_attributes
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
menu_link_attributes
Merge requests
!21
Issue
#3238246
: Support multivalue checkboxes attribute elements
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Issue
#3238246
: Support multivalue checkboxes attribute elements
issue/menu_link_attributes-3238246:3238246-support-multivalue-checkboxes
into
8.x-1.x
Overview
0
Commits
1
Pipelines
2
Changes
1
Merged
Issue #3238246: Support multivalue checkboxes attribute elements
Julian Pustkuchen
requested to merge
issue/menu_link_attributes-3238246:3238246-support-multivalue-checkboxes
into
8.x-1.x
Aug 19, 2024
Overview
0
Commits
1
Pipelines
2
Changes
1
Closes
#3238246
0
0
Merge request reports
Compare
8.x-1.x
version 1
48732580
Aug 19, 2024
8.x-1.x (base)
and
latest version
latest version
48732580
1 commit,
Aug 28, 2024
version 1
48732580
1 commit,
Aug 19, 2024
1 file
+
9
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
menu_link_attributes.module
+
9
−
2
View file @ 48732580
Edit in single-file editor
Open in Web IDE
Show full file
@@ -111,12 +111,19 @@ function menu_link_attributes_form_menu_link_content_form_alter(array &$form, Fo
'#default_value'
=>
$menu_link_options
[
$attributes_key
][
$attribute_formatted
]
??
(
$info
[
'default_value'
]
??
''
),
];
// Fill options
if select lis
t.
if
(
$type
==
'select'
)
{
// Fill options
for types that use i
t.
if
(
in_array
(
$type
,
[
'select'
,
'checkboxes'
,
'radios'
],
TRUE
)
)
{
$form
[
'options'
][
'attributes'
][
$attribute
][
'#empty_option'
]
=
t
(
'- Select -'
);
$form
[
'options'
][
'attributes'
][
$attribute
][
'#options'
]
=
$info
[
'options'
];
}
// Handle multivalue types.
if
(
in_array
(
$type
,
[
'checkboxes'
],
TRUE
)
&&
is_scalar
(
$form
[
'options'
][
'attributes'
][
$attribute
][
'#default_value'
]))
{
// Reverse what \Drupal\Core\Template\AttributeArray::__toString() does.
$array
=
array_filter
(
explode
(
' '
,
$form
[
'options'
][
'attributes'
][
$attribute
][
'#default_value'
]));
$form
[
'options'
][
'attributes'
][
$attribute
][
'#default_value'
]
=
$array
;
}
// Fill options if type is "managed_file".
if
(
$type
===
'managed_file'
&&
!
empty
(
$info
[
'upload_location'
]))
{
$form
[
'options'
][
'attributes'
][
$attribute
][
'#upload_location'
]
=
$info
[
'upload_location'
];
Loading