Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
9b5afa85
Commit
9b5afa85
authored
Oct 30, 2013
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2099417
by marthinal, swentel, lauriii: Fixed Unable to change Custom Block view mode.
parent
2280ad5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Block/CustomBlockBlock.php
...lib/Drupal/custom_block/Plugin/Block/CustomBlockBlock.php
+1
-0
core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php
...lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php
+21
-1
No files found.
core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Block/CustomBlockBlock.php
View file @
9b5afa85
...
...
@@ -113,6 +113,7 @@ public function blockForm($form, &$form_state) {
public
function
blockSubmit
(
$form
,
&
$form_state
)
{
// Invalidate the block cache to update custom block-based derivatives.
if
(
$this
->
moduleHandler
->
moduleExists
(
'block'
))
{
$this
->
configuration
[
'view_mode'
]
=
$form_state
[
'values'
][
'custom_block'
][
'view_mode'
];
$this
->
blockManager
->
clearCachedDefinitions
();
}
}
...
...
core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php
View file @
9b5afa85
...
...
@@ -46,9 +46,21 @@ protected function setUp() {
* Creates a "Basic page" block and verifies its consistency in the database.
*/
public
function
testCustomBlockCreation
()
{
// Add a new view mode and verify if it is selected as expected.
$this
->
drupalLogin
(
$this
->
drupalCreateUser
(
array
(
'administer display modes'
)));
$this
->
drupalGet
(
'admin/structure/display-modes/view/add/custom_block'
);
$edit
=
array
(
'id'
=>
'test_view_mode'
,
'label'
=>
'Test View Mode'
,
);
$this
->
drupalPostForm
(
NULL
,
$edit
,
t
(
'Save'
));
$this
->
assertRaw
(
t
(
'Saved the %label view mode.'
,
array
(
'%label'
=>
$edit
[
'label'
])));
$this
->
drupalLogin
(
$this
->
adminUser
);
// Create a block.
$edit
=
array
();
$edit
[
'info'
]
=
$this
->
randomName
(
8
)
;
$edit
[
'info'
]
=
'Test Block'
;
$edit
[
'body[0][value]'
]
=
$this
->
randomName
(
16
);
$this
->
drupalPostForm
(
'block/add/basic'
,
$edit
,
t
(
'Save'
));
...
...
@@ -58,6 +70,14 @@ public function testCustomBlockCreation() {
'%name'
=>
$edit
[
"info"
]
)),
'Basic block created.'
);
// Change the view mode.
$view_mode
[
'settings[custom_block][view_mode]'
]
=
'test_view_mode'
;
$this
->
drupalPostForm
(
NULL
,
$view_mode
,
t
(
'Save block'
));
// Go to the configure page and verify that the new view mode is correct.
$this
->
drupalGet
(
'admin/structure/block/manage/testblock'
);
$this
->
assertFieldByXPath
(
'//select[@name="settings[custom_block][view_mode]"]/option[@selected="selected"]/@value'
,
'test_view_mode'
,
'View mode changed to Test View Mode'
);
// Check that the block exists in the database.
$blocks
=
entity_load_multiple_by_properties
(
'custom_block'
,
array
(
'info'
=>
$edit
[
'info'
]));
$block
=
reset
(
$blocks
);
...
...
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