Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
301
Merge Requests
301
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
cdebbfb7
Commit
cdebbfb7
authored
Aug 25, 2014
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2321515
by dawehner: Fixed Updating links loses fragments.
parent
0d86fa90
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
9 deletions
+24
-9
core/modules/menu_link_content/src/Form/MenuLinkContentForm.php
...odules/menu_link_content/src/Form/MenuLinkContentForm.php
+11
-9
core/modules/menu_ui/src/Tests/MenuTest.php
core/modules/menu_ui/src/Tests/MenuTest.php
+13
-0
No files found.
core/modules/menu_link_content/src/Form/MenuLinkContentForm.php
View file @
cdebbfb7
...
...
@@ -260,16 +260,18 @@ public function form(array $form, FormStateInterface $form_state) {
// which need a replacement since it is deprecated.
// https://www.drupal.org/node/2307061
$default_value
=
$url
->
getInternalPath
();
// @todo Add a helper method to Url to render just the query string and
// fragment. https://www.drupal.org/node/2305013
$options
=
$url
->
getOptions
();
if
(
isset
(
$options
[
'query'
]))
{
$default_value
.
=
$options
[
'query'
]
?
(
'?'
.
UrlHelper
::
buildQuery
(
$options
[
'query'
]))
:
''
;
}
if
(
isset
(
$options
[
'fragment'
])
&&
$options
[
'fragment'
]
!==
''
)
{
$default_value
.
=
'#'
.
$options
[
'fragment'
];
}
}
// @todo Add a helper method to Url to render just the query string and
// fragment. https://www.drupal.org/node/2305013
$options
=
$url
->
getOptions
();
if
(
isset
(
$options
[
'query'
]))
{
$default_value
.
=
$options
[
'query'
]
?
(
'?'
.
UrlHelper
::
buildQuery
(
$options
[
'query'
]))
:
''
;
}
if
(
isset
(
$options
[
'fragment'
])
&&
$options
[
'fragment'
]
!==
''
)
{
$default_value
.
=
'#'
.
$options
[
'fragment'
];
}
$form
[
'url'
]
=
array
(
'#title'
=>
$this
->
t
(
'Link path'
),
'#type'
=>
'textfield'
,
...
...
core/modules/menu_ui/src/Tests/MenuTest.php
View file @
cdebbfb7
...
...
@@ -458,6 +458,19 @@ function testMenuQueryAndFragment() {
$this
->
drupalPostForm
(
'admin/structure/menu/item/'
.
$item
->
id
()
.
'/edit'
,
array
(
'url'
=>
$path
),
t
(
'Save'
));
$this
->
drupalGet
(
'admin/structure/menu/item/'
.
$item
->
id
()
.
'/edit'
);
$this
->
assertFieldByName
(
'url'
,
$path
,
'Path no longer has query or fragment.'
);
// Use <front>#fragment and ensure that saving it does not loose its
// content.
$path
=
'<front>?arg1=value#fragment'
;
$item
=
$this
->
addMenuLink
(
''
,
$path
);
$this
->
drupalGet
(
'admin/structure/menu/item/'
.
$item
->
id
()
.
'/edit'
);
$this
->
assertFieldByName
(
'url'
,
$path
,
'Path is found with both query and fragment.'
);
$this
->
drupalPostForm
(
'admin/structure/menu/item/'
.
$item
->
id
()
.
'/edit'
,
array
(),
t
(
'Save'
));
$this
->
drupalGet
(
'admin/structure/menu/item/'
.
$item
->
id
()
.
'/edit'
);
$this
->
assertFieldByName
(
'url'
,
$path
,
'Path is found with both query and fragment.'
);
}
/**
...
...
Write
Preview
Markdown
is supported
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