Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
menu_ui_async_widget
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
menu_ui_async_widget
Commits
17923a3a
Commit
17923a3a
authored
5 months ago
by
Yurii Panchuk
Committed by
Peter Törnstrand
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3490844
by panchuk: Inherit default values of menu_ui
parent
c48c9cc5
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!2
Issue #3490844: Inherit default values of menu_ui
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
menu_ui_async_widget.module
+16
-2
16 additions, 2 deletions
menu_ui_async_widget.module
with
16 additions
and
2 deletions
menu_ui_async_widget.module
+
16
−
2
View file @
17923a3a
...
...
@@ -273,8 +273,10 @@ function menu_ui_async_widget_form_node_type_form_alter(&$form, FormStateInterfa
return
$menu
->
label
();
},
Menu
::
loadMultiple
());
asort
(
$menu_options
);
/** @var \Drupal\node\NodeTypeInterface $type */
$type
=
$form_state
->
getFormObject
()
->
getEntity
();
$form
[
'menu_async'
]
=
[
'#type'
=>
'details'
,
'#title'
=>
t
(
'Menu UI Async settings'
),
...
...
@@ -283,13 +285,19 @@ function menu_ui_async_widget_form_node_type_form_alter(&$form, FormStateInterfa
],
'#group'
=>
'additional_settings'
,
];
// Inherit default menus values from default menu settings.
$default_menus
=
$type
->
getThirdPartySetting
(
'menu_ui'
,
'available_menus'
,
[
'main'
]);
$default_menus_async
=
$type
->
getThirdPartySetting
(
'menu_ui_async_widget'
,
'available_menus'
,
$default_menus
);
$form
[
'menu_async'
][
'menu_async_options'
]
=
[
'#type'
=>
'checkboxes'
,
'#title'
=>
t
(
'Available menus'
),
'#default_value'
=>
$
type
->
getThirdPartySetting
(
'
menu
_ui
_async
_widget'
,
'available_menus'
,
[
'main'
])
,
'#default_value'
=>
$
default_
menu
s
_async
,
'#options'
=>
$menu_options
,
'#description'
=>
t
(
'The menus available to place links in for this content type.'
),
];
// @todo See if we can avoid pre-loading all options by changing the form or
// using a #process callback. https://www.drupal.org/node/2310319
// To avoid an 'illegal option' error after saving the form we have to load
...
...
@@ -297,14 +305,20 @@ function menu_ui_async_widget_form_node_type_form_alter(&$form, FormStateInterfa
// add options to the list using ajax.
$options_cacheability
=
new
CacheableMetadata
();
$options
=
$menu_parent_selector
->
getParentSelectOptions
(
''
,
NULL
,
$options_cacheability
);
// Inherit selected parent menu item from default menu settings.
$default_menu_item
=
$type
->
getThirdPartySetting
(
'menu_ui'
,
'parent'
,
'main:'
);
$default_menu_item_async
=
$type
->
getThirdPartySetting
(
'menu_ui_async_widget'
,
'parent'
,
$default_menu_item
);
$form
[
'menu_async'
][
'menu_async_parent'
]
=
[
'#type'
=>
'select'
,
'#title'
=>
t
(
'Default parent link'
),
'#default_value'
=>
$
type
->
getThirdPartySetting
(
'
menu_
u
i_async
_widget'
,
'parent'
,
'main:'
)
,
'#default_value'
=>
$
default_
menu_i
tem
_async
,
'#options'
=>
$options
,
'#description'
=>
t
(
'Choose the menu link to be the default parent for a new link in the content authoring form.'
),
'#attributes'
=>
[
'class'
=>
[
'menu-title-select'
]],
];
$options_cacheability
->
applyTo
(
$form
[
'menu_async'
][
'menu_async_parent'
]);
$form
[
'#validate'
][]
=
'menu_ui_async_widget_form_node_type_form_validate'
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment