Skip to content

Commit 6fa06cc

Browse files
committed
fix the bugs no display the websites tab on the add new FAQ and Category pages
1 parent 5ccc604 commit 6fa06cc

File tree

2 files changed

+39
-57
lines changed

2 files changed

+39
-57
lines changed

Block/Adminhtml/Faq/Edit/Tab/Websites.php

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -109,35 +109,26 @@ protected function _prepareForm()
109109
$this->_addElementTypes($fieldset);
110110

111111
$formData = $this->_coreRegistry->registry('phpcuong_faq');
112-
113-
/**
114-
* Check is single store mode
115-
*/
116-
if (!$this->_storeManager->hasSingleStore()) {
117-
$field = $fieldset->addField(
118-
'stores',
119-
'multiselect',
120-
[
121-
'label' => __('Stores View'),
122-
'title' => __('Stores View'),
123-
'required' => true,
124-
'name' => 'stores[]',
125-
'values' => $this->_systemStore->getStoreValuesForForm(false, true)
126-
]
127-
);
128-
$renderer = $this->getLayout()->createBlock(
129-
'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element'
130-
);
131-
$field->setRenderer($renderer);
132-
$formData->setSelectStores($formData->getStores());
133-
} else {
134-
$fieldset->addField(
135-
'stores',
136-
'hidden',
137-
['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]
138-
);
139-
$formData->setSelectStores($this->_storeManager->getStore(true)->getId());
140-
}
112+
113+
$field = $fieldset->addField(
114+
'stores',
115+
'multiselect',
116+
[
117+
'label' => __('Stores View'),
118+
'title' => __('Stores View'),
119+
'required' => true,
120+
'name' => 'stores[]',
121+
'values' => $this->_systemStore->getStoreValuesForForm(false, true)
122+
]
123+
);
124+
125+
$renderer = $this->getLayout()->createBlock(
126+
'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element'
127+
);
128+
129+
$field->setRenderer($renderer);
130+
131+
$formData->setSelectStores($formData->getStores());
141132

142133
if ($formData) {
143134
if ($formData->getStores() == null) {

Block/Adminhtml/Faqcat/Edit/Tab/Websites.php

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -110,34 +110,25 @@ protected function _prepareForm()
110110

111111
$formData = $this->_coreRegistry->registry('phpcuong_faqcat');
112112

113-
/**
114-
* Check is single store mode
115-
*/
116-
if (!$this->_storeManager->hasSingleStore()) {
117-
$field = $fieldset->addField(
118-
'stores',
119-
'multiselect',
120-
[
121-
'label' => __('Stores View'),
122-
'title' => __('Stores View'),
123-
'required' => true,
124-
'name' => 'stores[]',
125-
'values' => $this->_systemStore->getStoreValuesForForm(false, true)
126-
]
127-
);
128-
$renderer = $this->getLayout()->createBlock(
129-
'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element'
130-
);
131-
$field->setRenderer($renderer);
132-
$formData->setSelectStores($formData->getStores());
133-
} else {
134-
$fieldset->addField(
135-
'stores',
136-
'hidden',
137-
['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]
138-
);
139-
$formData->setSelectStores($this->_storeManager->getStore(true)->getId());
140-
}
113+
$field = $fieldset->addField(
114+
'stores',
115+
'multiselect',
116+
[
117+
'label' => __('Stores View'),
118+
'title' => __('Stores View'),
119+
'required' => true,
120+
'name' => 'stores[]',
121+
'values' => $this->_systemStore->getStoreValuesForForm(false, true)
122+
]
123+
);
124+
125+
$renderer = $this->getLayout()->createBlock(
126+
'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element'
127+
);
128+
129+
$field->setRenderer($renderer);
130+
131+
$formData->setSelectStores($formData->getStores());
141132

142133
if ($formData) {
143134
if ($formData->getStores() == null) {

0 commit comments

Comments
 (0)