Skip to content

Commit 24c022e

Browse files
committed
Resolve "New Block" form still show "Store View" field in "Single Store Mode" issue24387
1 parent e56640c commit 24c022e

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Cms\Ui\Component\Form\Field;
9+
10+
use Magento\Framework\View\Element\UiComponent\ContextInterface;
11+
use Magento\Framework\View\Element\UiComponentFactory;
12+
use Magento\Framework\View\Element\UiComponentInterface;
13+
use Magento\Store\Model\StoreManagerInterface as StoreManager;
14+
use Magento\Ui\Component\Form\Field;
15+
16+
/**
17+
* Check to disable store view field
18+
*
19+
* Class \Magento\Cms\Ui\Component\Form\Field\StoreView
20+
*/
21+
class StoreView extends Field
22+
{
23+
/**
24+
* Store manager
25+
*
26+
* @var StoreManager
27+
*/
28+
private $storeManager;
29+
30+
/**
31+
* StoreView constructor.
32+
*
33+
* @param ContextInterface $context
34+
* @param UiComponentFactory $uiComponentFactory
35+
* @param StoreManager $storeManager
36+
* @param array $components
37+
* @param array $data
38+
*/
39+
public function __construct(
40+
ContextInterface $context,
41+
UiComponentFactory $uiComponentFactory,
42+
StoreManager $storeManager,
43+
array $components = [],
44+
array $data = []
45+
) {
46+
parent::__construct($context, $uiComponentFactory, $components, $data);
47+
$this->storeManager = $storeManager;
48+
}
49+
50+
/**
51+
* Prepare component configuration
52+
*
53+
* @return void
54+
*/
55+
public function prepare()
56+
{
57+
parent::prepare();
58+
if ($this->storeManager->isSingleStoreMode()) {
59+
$this->_data['config']['componentDisabled'] = true;
60+
}
61+
}
62+
}

app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
<dataScope>identifier</dataScope>
112112
</settings>
113113
</field>
114-
<field name="storeviews" formElement="multiselect">
114+
<field name="storeviews" formElement="multiselect" class="Magento\Cms\Ui\Component\Form\Field\StoreView">
115115
<argument name="data" xsi:type="array">
116116
<item name="config" xsi:type="array">
117117
<item name="source" xsi:type="string">block</item>

0 commit comments

Comments
 (0)