Closed devidass closed 7 years ago
Please change below files :
PHPCuong\Faq\Block\Adminhtml\Faqcat\Edit\Tab\Websites.php
`<?php
/*
namespace PHPCuong\Faq\Block\Adminhtml\Faqcat\Edit\Tab;
use Magento\Store\Model\Store;
class Websites extends \Magento\Backend\Block\Widget\Form\Generic implements \Magento\Backend\Block\Widget\Tab\TabInterface { /**
@var \Magento\Framework\Registry */ protected $_coreRegistry;
/**
@var \Magento\Store\Model\System\Store */ protected $_systemStore;
/**
@param array $data */ public function __construct( \Magento\Store\Model\System\Store $systemStore, \Magento\Backend\Block\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, array $data = [] ) { $this->_systemStore = $systemStore; parent::__construct($context, $registry, $formFactory, $data); }
/**
@return void */ protected function _construct() { parent::_construct(); $this->setActive(true); }
/**
@return \Magento\Framework\Phrase */ public function getTabLabel() { return __('FAQ Category in Websites'); }
/**
@return \Magento\Framework\Phrase */ public function getTabTitle() { return $this->getTabLabel(); }
/**
@return true */ public function canShowTab() { return true; }
/**
@return true */ public function isHidden() { return false; }
/**
@return $this */ protected function _prepareForm() { /* @var \Magento\Framework\Data\Form $form / $form = $this->_formFactory->create();
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('FAQ Category in Websites')]);
$this->_addElementTypes($fieldset);
$formData = $this->_coreRegistry->registry('phpcuong_faqcat');
/**
* Check is single store mode
*/
// if (!$this->_storeManager->hasSingleStore()) { $field = $fieldset->addField( 'stores', 'multiselect', [ 'label' => ('Stores View'), 'title' => ('Stores View'), 'required' => true, 'name' => 'stores[]', 'values' => $this->_systemStore->getStoreValuesForForm(false, true) ] ); $renderer = $this->getLayout()->createBlock( 'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element' ); $field->setRenderer($renderer); $formData->setSelectStores($formData->getStores()); / } else { $fieldset->addField( 'stores', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()] ); $formData->setSelectStores($this->_storeManager->getStore(true)->getId()); }/
if ($formData) {
if ($formData->getStores() == null) {
$formData->setStores([Store::DEFAULT_STORE_ID]);
}
$form->setValues($formData->getData());
}
$this->setForm($form);
return parent::_prepareForm();
} } `
PHPCuong\Faq\Block\Adminhtml\Faq\Edit\Tab\Websites.php
`<?php
/*
namespace PHPCuong\Faq\Block\Adminhtml\Faq\Edit\Tab;
use Magento\Store\Model\Store;
class Websites extends \Magento\Backend\Block\Widget\Form\Generic implements \Magento\Backend\Block\Widget\Tab\TabInterface { /**
@var \Magento\Framework\Registry */ protected $_coreRegistry;
/**
@var \Magento\Store\Model\System\Store */ protected $_systemStore;
/**
@param array $data */ public function __construct( \Magento\Store\Model\System\Store $systemStore, \Magento\Backend\Block\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, array $data = [] ) { $this->_systemStore = $systemStore; parent::__construct($context, $registry, $formFactory, $data); }
/**
@return void */ protected function _construct() { parent::_construct(); $this->setActive(true); }
/**
@return \Magento\Framework\Phrase */ public function getTabLabel() { return __('FAQ in Websites'); }
/**
@return \Magento\Framework\Phrase */ public function getTabTitle() { return $this->getTabLabel(); }
/**
@return true */ public function canShowTab() { return true; }
/**
@return true */ public function isHidden() { return false; }
/**
@return $this */ protected function _prepareForm() { /* @var \Magento\Framework\Data\Form $form / $form = $this->_formFactory->create();
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('FAQ in Websites')]);
$this->_addElementTypes($fieldset);
$formData = $this->_coreRegistry->registry('phpcuong_faq');
/**
* Check is single store mode
*/
// if (!$this->_storeManager->hasSingleStore()) { $field = $fieldset->addField( 'stores', 'multiselect', [ 'label' => ('Stores View'), 'title' => ('Stores View'), 'required' => true, 'name' => 'stores[]', 'values' => $this->_systemStore->getStoreValuesForForm(false, true) ] ); $renderer = $this->getLayout()->createBlock( 'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element' ); $field->setRenderer($renderer); $formData->setSelectStores($formData->getStores()); /} else { $fieldset->addField( 'stores', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()] ); $formData->setSelectStores($this->_storeManager->getStore(true)->getId()); }/
if ($formData) {
if ($formData->getStores() == null) {
$formData->setStores([Store::DEFAULT_STORE_ID]);
}
$form->setValues($formData->getData());
}
$this->setForm($form);
return parent::_prepareForm();
} } `
Above code is tested .
Hope will work at your end.
Thanks.
The problem was fixed, please pull the latest code.
I am not able to make any kind of changes in your extension. Please help me to resolve this issue. Eagerly waiting for your positive reply. Thanks & Regards Devidas K