Skip to main content
added 4 characters in body
Source Link
LinoPham
  • 3.8k
  • 5
  • 23
  • 46

You should inject class Magento\Store\Model\System\Store in the constructor and declare a global variable.

E.g:

public function __construct(
   //...,
   Magento\Store\Model\System\Store $systemStore
) {
   //...
  $this->_systemStore = $systemStore;
}

protected function _prepareForm()
{
    //...
    $fieldset->addField(
       'store_ids',
       'multiselect',
       [
         'name'     => 'store_ids[]',
         'label'    => __('Store Views'),
         'title'    => __('Store Views'),
         'required' => true,
         'values'   => $this->_systemStore->getStoreValuesForForm(false, true),
       ]
    );
}

I hope it was helpful.

You should inject class Magento\Store\Model\System\Store in constructor and declare a global variable.

E.g:

public function __construct(
   //...,
   Magento\Store\Model\System\Store $systemStore
) {
   //...
  $this->_systemStore = $systemStore;
}

protected function _prepareForm()
{
    //...
    $fieldset->addField(
       'store_ids',
       'multiselect',
       [
         'name'     => 'store_ids[]',
         'label'    => __('Store Views'),
         'title'    => __('Store Views'),
         'required' => true,
         'values'   => $this->_systemStore->getStoreValuesForForm(false, true),
       ]
    );
}

I hope it was helpful.

You should inject class Magento\Store\Model\System\Store in the constructor and declare a global variable.

E.g:

public function __construct(
   //...,
   Magento\Store\Model\System\Store $systemStore
) {
   //...
  $this->_systemStore = $systemStore;
}

protected function _prepareForm()
{
    //...
    $fieldset->addField(
       'store_ids',
       'multiselect',
       [
         'name'     => 'store_ids[]',
         'label'    => __('Store Views'),
         'title'    => __('Store Views'),
         'required' => true,
         'values'   => $this->_systemStore->getStoreValuesForForm(false, true),
       ]
    );
}

I hope it was helpful.

added 105 characters in body
Source Link
LinoPham
  • 3.8k
  • 5
  • 23
  • 46

You should inject class Magento\Store\Model\System\Store in constructor and declare a global variable.

E.g:

public function __construct(
   //...,
   Magento\Store\Model\System\Store $systemStore
) {
   //...
  $this->_systemStore = $systemStore;
}

protected function _prepareForm()
{
    //...
    $fieldset->addField(
       'store_ids',
       'multiselect',
       [
         'name'     => 'store_ids[]',
         'label'    => __('Store Views'),
         'title'    => __('Store Views'),
         'required' => true,
         'values'   => $this->_systemStore->getStoreValuesForForm(false, true),
       ]
    );
}

I hope it was helpful.

You should inject class Magento\Store\Model\System\Store in constructor and declare a global variable.

E.g:

public function __construct(
   //...,
   Magento\Store\Model\System\Store $systemStore
) {
   //...
  $this->_systemStore = $systemStore;
}

 $fieldset->addField(
     'store_ids',
     'multiselect',
     [
         'name'     => 'store_ids[]',
         'label'    => __('Store Views'),
         'title'    => __('Store Views'),
         'required' => true,
         'values'   => $this->_systemStore->getStoreValuesForForm(false, true),
     ]
  );

You should inject class Magento\Store\Model\System\Store in constructor and declare a global variable.

E.g:

public function __construct(
   //...,
   Magento\Store\Model\System\Store $systemStore
) {
   //...
  $this->_systemStore = $systemStore;
}

protected function _prepareForm()
{
    //...
    $fieldset->addField(
       'store_ids',
       'multiselect',
       [
         'name'     => 'store_ids[]',
         'label'    => __('Store Views'),
         'title'    => __('Store Views'),
         'required' => true,
         'values'   => $this->_systemStore->getStoreValuesForForm(false, true),
       ]
    );
}

I hope it was helpful.

Source Link
LinoPham
  • 3.8k
  • 5
  • 23
  • 46

You should inject class Magento\Store\Model\System\Store in constructor and declare a global variable.

E.g:

public function __construct(
   //...,
   Magento\Store\Model\System\Store $systemStore
) {
   //...
  $this->_systemStore = $systemStore;
}

 $fieldset->addField(
     'store_ids',
     'multiselect',
     [
         'name'     => 'store_ids[]',
         'label'    => __('Store Views'),
         'title'    => __('Store Views'),
         'required' => true,
         'values'   => $this->_systemStore->getStoreValuesForForm(false, true),
     ]
  );