Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
821a9ce8
Commit
821a9ce8
authored
Dec 03, 2014
by
alexpott
Browse files
Issue
#2275463
by SpadXIII: Path field does not respect settings in form display
parent
a9614d53
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/modules/path/path.module
View file @
821a9ce8
...
...
@@ -42,22 +42,21 @@ function path_help($route_name, RouteMatchInterface $route_match) {
*/
function
path_form_node_form_alter
(
&
$form
,
FormStateInterface
$form_state
)
{
$node
=
$form_state
->
getFormObject
()
->
getEntity
();
if
(
$node
->
hasField
(
'path'
)
&&
$node
->
get
(
'path'
)
->
access
(
'edit'
))
{
$form
[
'path_settings'
]
=
array
(
'#type'
=>
'details'
,
'#title'
=>
t
(
'URL path settings'
),
'#open'
=>
!
empty
(
$form
[
'path'
][
'widget'
][
0
][
'alias'
][
'#value'
]),
'#group'
=>
'advanced'
,
'#attributes'
=>
array
(
'class'
=>
array
(
'path-form'
),
),
'#attached'
=>
array
(
'library'
=>
array
(
'path/drupal.path'
),
),
'#weight'
=>
30
,
);
$form
[
'path'
][
'#group'
]
=
'path_settings'
;
}
$form
[
'path_settings'
]
=
array
(
'#type'
=>
'details'
,
'#title'
=>
t
(
'URL path settings'
),
'#open'
=>
!
empty
(
$form
[
'path'
][
'widget'
][
0
][
'alias'
][
'#value'
]),
'#group'
=>
'advanced'
,
'#access'
=>
!
empty
(
$form
[
'path'
][
'#access'
])
&&
$node
->
hasField
(
'path'
)
&&
$node
->
get
(
'path'
)
->
access
(
'edit'
),
'#attributes'
=>
array
(
'class'
=>
array
(
'path-form'
),
),
'#attached'
=>
array
(
'library'
=>
array
(
'path/drupal.path'
),
),
'#weight'
=>
30
,
);
$form
[
'path'
][
'#group'
]
=
'path_settings'
;
}
/**
...
...
core/modules/path/src/Tests/PathNodeFormTest.php
0 → 100644
View file @
821a9ce8
<?php
/**
* @file
* Contains \Drupal\path\Tests\PathNodeFormTest.
*/
namespace
Drupal\path\Tests
;
/**
* Tests the Path Node form UI.
*
* @group path
*/
class
PathNodeFormTest
extends
PathTestBase
{
/**
* Modules to enable.
*
* @var array
*/
public
static
$modules
=
array
(
'node'
,
'path'
);
protected
function
setUp
()
{
parent
::
setUp
();
// Create test user and login.
$web_user
=
$this
->
drupalCreateUser
(
array
(
'create page content'
,
'create url aliases'
));
$this
->
drupalLogin
(
$web_user
);
}
/**
* Tests the node form ui.
*/
public
function
testNodeForm
()
{
$this
->
drupalGet
(
'node/add/page'
);
// Make sure we have a Path fieldset and Path fields.
$this
->
assertRaw
(
' id="edit-path-settings"'
,
'Path settings details exists'
);
$this
->
assertFieldByName
(
'path[0][alias]'
,
NULL
,
'Path alias field exists'
);
// Disable the Path field for this content type.
entity_get_form_display
(
'node'
,
'page'
,
'default'
)
->
removeComponent
(
'path'
)
->
save
();
$this
->
drupalGet
(
'node/add/page'
);
// See if the whole fieldset is gone now.
$this
->
assertNoRaw
(
' id="edit-path-settings"'
,
'Path settings details does not exist'
);
$this
->
assertNoFieldByName
(
'path[0][alias]'
,
NULL
,
'Path alias field does not exist'
);
}
}
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