Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WCMS
uw_sites_all
Commits
d503cdd6
Commit
d503cdd6
authored
Sep 17, 2020
by
Liam Morland
Browse files
ISTWCMS-4086: Redirect to layout edit page on node creation
parent
2cc80f16
Changes
1
Hide whitespace changes
Inline
Side-by-side
uw_sites_all.module
View file @
d503cdd6
...
...
@@ -5,6 +5,31 @@
* Workbench module file.
*/
use
Drupal\Core\Form\FormStateInterface
;
/**
* Implements hook_form_BASE_FORM_ID_alter().
*/
function
uw_sites_all_form_node_form_alter
(
array
&
$form
,
FormStateInterface
$form_state
,
string
$form_id
):
void
{
// Only on node add forms for content types that use Layout Builder, add
// submit handler.
$fieldDefinitions
=
$form
[
'#process'
][
1
][
0
]
->
get
(
'fieldDefinitions'
);
if
(
isset
(
$fieldDefinitions
[
'layout_builder__layout'
])
&&
substr
(
$form_id
,
-
10
)
!==
'_edit_form'
)
{
$form
[
'actions'
][
'submit'
][
'#submit'
][]
=
'_uw_sites_all_form_node_form_submit'
;
}
}
/**
* Form submit handler.
*/
function
_uw_sites_all_form_node_form_submit
(
array
$form
,
FormStateInterface
&
$form_state
):
void
{
// Redirect to layout tab on form submit.
$nid
=
$form_state
->
getValue
(
'nid'
);
if
(
$nid
)
{
$form_state
->
setRedirect
(
'layout_builder.overrides.node.view'
,
[
'node'
=>
$nid
]);
}
}
/**
* Implements hook_link_alter().
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment