Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
1efd2ad0
Commit
1efd2ad0
authored
Apr 17, 2014
by
Angie Byron
Browse files
Issue
#2231413
by blueminds, tim.plunkett: Link field does not accept a valid path alias.
parent
6f0f10b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/modules/link/lib/Drupal/link/Plugin/Field/FieldWidget/LinkWidget.php
View file @
1efd2ad0
...
...
@@ -207,6 +207,12 @@ public function massageFormValues(array $values, array $form, array &$form_state
try
{
$parsed_url
=
UrlHelper
::
parse
(
$value
[
'url'
]);
// If internal links are supported, look up whether the given value is
// a path alias and store the system path instead.
if
(
$this
->
supportsInternalLinks
()
&&
!
UrlHelper
::
isExternal
(
$value
[
'url'
]))
{
$parsed_url
[
'path'
]
=
\
Drupal
::
service
(
'path.alias_manager.cached'
)
->
getSystemPath
(
$parsed_url
[
'path'
]);
}
$url
=
Url
::
createFromPath
(
$parsed_url
[
'path'
]);
$url
->
setOption
(
'query'
,
$parsed_url
[
'query'
]);
$url
->
setOption
(
'fragment'
,
$parsed_url
[
'fragment'
]);
...
...
core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php
View file @
1efd2ad0
...
...
@@ -103,12 +103,15 @@ function testURLValidation() {
$this
->
assertFieldByName
(
"
{
$field_name
}
[0][url]"
,
''
,
'Link URL field is displayed'
);
$this
->
assertRaw
(
'placeholder="http://example.com"'
);
// Create a path alias.
\
Drupal
::
service
(
'path.alias_storage'
)
->
save
(
'admin'
,
'a/path/alias'
);
// Define some valid URLs.
$valid_external_entries
=
array
(
'http://www.example.com/'
,
);
$valid_internal_entries
=
array
(
'entity_test/add'
,
'a/path/alias'
,
);
// Define some invalid URLs.
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment