Magento 2 Store View multiselect in system.xml





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I am not able to add store view selection in system.xml I am only able to add in the ui form field component:



When I tried to add in system.xml it gives the error:



1 exception(s):
Exception #0 (Exception): Warning: htmlspecialchars() expects parameter 1 to be string,
array given in
.../vendor/magento/framework/Data/Form/Element/AbstractElement.php on line 287


system.xml:



<field id="store_view" translate="label" type="multiselect" sortOrder="13" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Store view</label>
<source_model>MagentoCmsUiComponentListingColumnCmsOptions</source_model>
</field>


form_edit.xml



<field name="store">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">MagentoCmsUiComponentListingColumnCmsOptions/item>
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Store</item>
<item name="visible" xsi:type="boolean">true</item>
<item name="dataType" xsi:type="string">number</item>
<item name="formElement" xsi:type="string">multiselect</item>
<item name="source" xsi:type="string">store</item>
<item name="multiple" xsi:type="boolean">true</item>
<item name="dataScope" xsi:type="string">store</item>
<item name="valueMap" xsi:type="array">
<item name="true" xsi:type="number">1</item>
<item name="false" xsi:type="number">0</item>
</item>
<item name="default" xsi:type="number">0</item>
</item>
</argument>
</field>


enter image description here



Is it possible at all the way magento has build this?










share|improve this question





























    0















    I am not able to add store view selection in system.xml I am only able to add in the ui form field component:



    When I tried to add in system.xml it gives the error:



    1 exception(s):
    Exception #0 (Exception): Warning: htmlspecialchars() expects parameter 1 to be string,
    array given in
    .../vendor/magento/framework/Data/Form/Element/AbstractElement.php on line 287


    system.xml:



    <field id="store_view" translate="label" type="multiselect" sortOrder="13" showInDefault="1" showInWebsite="1" showInStore="1">
    <label>Store view</label>
    <source_model>MagentoCmsUiComponentListingColumnCmsOptions</source_model>
    </field>


    form_edit.xml



    <field name="store">
    <argument name="data" xsi:type="array">
    <item name="options" xsi:type="object">MagentoCmsUiComponentListingColumnCmsOptions/item>
    <item name="config" xsi:type="array">
    <item name="label" xsi:type="string" translate="true">Store</item>
    <item name="visible" xsi:type="boolean">true</item>
    <item name="dataType" xsi:type="string">number</item>
    <item name="formElement" xsi:type="string">multiselect</item>
    <item name="source" xsi:type="string">store</item>
    <item name="multiple" xsi:type="boolean">true</item>
    <item name="dataScope" xsi:type="string">store</item>
    <item name="valueMap" xsi:type="array">
    <item name="true" xsi:type="number">1</item>
    <item name="false" xsi:type="number">0</item>
    </item>
    <item name="default" xsi:type="number">0</item>
    </item>
    </argument>
    </field>


    enter image description here



    Is it possible at all the way magento has build this?










    share|improve this question

























      0












      0








      0








      I am not able to add store view selection in system.xml I am only able to add in the ui form field component:



      When I tried to add in system.xml it gives the error:



      1 exception(s):
      Exception #0 (Exception): Warning: htmlspecialchars() expects parameter 1 to be string,
      array given in
      .../vendor/magento/framework/Data/Form/Element/AbstractElement.php on line 287


      system.xml:



      <field id="store_view" translate="label" type="multiselect" sortOrder="13" showInDefault="1" showInWebsite="1" showInStore="1">
      <label>Store view</label>
      <source_model>MagentoCmsUiComponentListingColumnCmsOptions</source_model>
      </field>


      form_edit.xml



      <field name="store">
      <argument name="data" xsi:type="array">
      <item name="options" xsi:type="object">MagentoCmsUiComponentListingColumnCmsOptions/item>
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string" translate="true">Store</item>
      <item name="visible" xsi:type="boolean">true</item>
      <item name="dataType" xsi:type="string">number</item>
      <item name="formElement" xsi:type="string">multiselect</item>
      <item name="source" xsi:type="string">store</item>
      <item name="multiple" xsi:type="boolean">true</item>
      <item name="dataScope" xsi:type="string">store</item>
      <item name="valueMap" xsi:type="array">
      <item name="true" xsi:type="number">1</item>
      <item name="false" xsi:type="number">0</item>
      </item>
      <item name="default" xsi:type="number">0</item>
      </item>
      </argument>
      </field>


      enter image description here



      Is it possible at all the way magento has build this?










      share|improve this question














      I am not able to add store view selection in system.xml I am only able to add in the ui form field component:



      When I tried to add in system.xml it gives the error:



      1 exception(s):
      Exception #0 (Exception): Warning: htmlspecialchars() expects parameter 1 to be string,
      array given in
      .../vendor/magento/framework/Data/Form/Element/AbstractElement.php on line 287


      system.xml:



      <field id="store_view" translate="label" type="multiselect" sortOrder="13" showInDefault="1" showInWebsite="1" showInStore="1">
      <label>Store view</label>
      <source_model>MagentoCmsUiComponentListingColumnCmsOptions</source_model>
      </field>


      form_edit.xml



      <field name="store">
      <argument name="data" xsi:type="array">
      <item name="options" xsi:type="object">MagentoCmsUiComponentListingColumnCmsOptions/item>
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string" translate="true">Store</item>
      <item name="visible" xsi:type="boolean">true</item>
      <item name="dataType" xsi:type="string">number</item>
      <item name="formElement" xsi:type="string">multiselect</item>
      <item name="source" xsi:type="string">store</item>
      <item name="multiple" xsi:type="boolean">true</item>
      <item name="dataScope" xsi:type="string">store</item>
      <item name="valueMap" xsi:type="array">
      <item name="true" xsi:type="number">1</item>
      <item name="false" xsi:type="number">0</item>
      </item>
      <item name="default" xsi:type="number">0</item>
      </item>
      </argument>
      </field>


      enter image description here



      Is it possible at all the way magento has build this?







      magento2.2.2 store-view system.xml






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 15 hours ago









      Juliano VargasJuliano Vargas

      591523




      591523






















          1 Answer
          1






          active

          oldest

          votes


















          0














          system.xml :-



          <field id="store_view" translate="label" type="multiselect" sortOrder="13" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>Store view</label>
          <source_model>vendormoduleModelSourceConfigOption</source_model>
          </field>
          <?php


          option.php



          namespace vendormoduleModelSourceConfig;

          class Option implements MagentoFrameworkDataOptionSourceInterface
          {

          protected $eavConfig;


          public function __construct(
          MagentoStoreModelStoreManagerInterface $storeManager
          )
          {
          $this->_storeManager = $storeManager;
          }


          public function toOptionArray()
          {
          $storeManagerDataList = $this->_storeManager->getStores();
          $options = array();

          foreach ($storeManagerDataList as $key => $value) {
          $options = array(
          'value' => $value['name'],
          'label' => $value['code'],
          );
          }
          return $options;
          }
          }





          share|improve this answer


























          • That's not the answer. in need to show parent of store view also in similar fashion to the store view switcher, same as image attached in the question.

            – Juliano Vargas
            14 hours ago












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f268940%2fmagento-2-store-view-multiselect-in-system-xml%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          system.xml :-



          <field id="store_view" translate="label" type="multiselect" sortOrder="13" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>Store view</label>
          <source_model>vendormoduleModelSourceConfigOption</source_model>
          </field>
          <?php


          option.php



          namespace vendormoduleModelSourceConfig;

          class Option implements MagentoFrameworkDataOptionSourceInterface
          {

          protected $eavConfig;


          public function __construct(
          MagentoStoreModelStoreManagerInterface $storeManager
          )
          {
          $this->_storeManager = $storeManager;
          }


          public function toOptionArray()
          {
          $storeManagerDataList = $this->_storeManager->getStores();
          $options = array();

          foreach ($storeManagerDataList as $key => $value) {
          $options = array(
          'value' => $value['name'],
          'label' => $value['code'],
          );
          }
          return $options;
          }
          }





          share|improve this answer


























          • That's not the answer. in need to show parent of store view also in similar fashion to the store view switcher, same as image attached in the question.

            – Juliano Vargas
            14 hours ago
















          0














          system.xml :-



          <field id="store_view" translate="label" type="multiselect" sortOrder="13" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>Store view</label>
          <source_model>vendormoduleModelSourceConfigOption</source_model>
          </field>
          <?php


          option.php



          namespace vendormoduleModelSourceConfig;

          class Option implements MagentoFrameworkDataOptionSourceInterface
          {

          protected $eavConfig;


          public function __construct(
          MagentoStoreModelStoreManagerInterface $storeManager
          )
          {
          $this->_storeManager = $storeManager;
          }


          public function toOptionArray()
          {
          $storeManagerDataList = $this->_storeManager->getStores();
          $options = array();

          foreach ($storeManagerDataList as $key => $value) {
          $options = array(
          'value' => $value['name'],
          'label' => $value['code'],
          );
          }
          return $options;
          }
          }





          share|improve this answer


























          • That's not the answer. in need to show parent of store view also in similar fashion to the store view switcher, same as image attached in the question.

            – Juliano Vargas
            14 hours ago














          0












          0








          0







          system.xml :-



          <field id="store_view" translate="label" type="multiselect" sortOrder="13" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>Store view</label>
          <source_model>vendormoduleModelSourceConfigOption</source_model>
          </field>
          <?php


          option.php



          namespace vendormoduleModelSourceConfig;

          class Option implements MagentoFrameworkDataOptionSourceInterface
          {

          protected $eavConfig;


          public function __construct(
          MagentoStoreModelStoreManagerInterface $storeManager
          )
          {
          $this->_storeManager = $storeManager;
          }


          public function toOptionArray()
          {
          $storeManagerDataList = $this->_storeManager->getStores();
          $options = array();

          foreach ($storeManagerDataList as $key => $value) {
          $options = array(
          'value' => $value['name'],
          'label' => $value['code'],
          );
          }
          return $options;
          }
          }





          share|improve this answer















          system.xml :-



          <field id="store_view" translate="label" type="multiselect" sortOrder="13" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>Store view</label>
          <source_model>vendormoduleModelSourceConfigOption</source_model>
          </field>
          <?php


          option.php



          namespace vendormoduleModelSourceConfig;

          class Option implements MagentoFrameworkDataOptionSourceInterface
          {

          protected $eavConfig;


          public function __construct(
          MagentoStoreModelStoreManagerInterface $storeManager
          )
          {
          $this->_storeManager = $storeManager;
          }


          public function toOptionArray()
          {
          $storeManagerDataList = $this->_storeManager->getStores();
          $options = array();

          foreach ($storeManagerDataList as $key => $value) {
          $options = array(
          'value' => $value['name'],
          'label' => $value['code'],
          );
          }
          return $options;
          }
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 14 hours ago

























          answered 14 hours ago









          Ronak RathodRonak Rathod

          1,097213




          1,097213













          • That's not the answer. in need to show parent of store view also in similar fashion to the store view switcher, same as image attached in the question.

            – Juliano Vargas
            14 hours ago



















          • That's not the answer. in need to show parent of store view also in similar fashion to the store view switcher, same as image attached in the question.

            – Juliano Vargas
            14 hours ago

















          That's not the answer. in need to show parent of store view also in similar fashion to the store view switcher, same as image attached in the question.

          – Juliano Vargas
          14 hours ago





          That's not the answer. in need to show parent of store view also in similar fashion to the store view switcher, same as image attached in the question.

          – Juliano Vargas
          14 hours ago


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f268940%2fmagento-2-store-view-multiselect-in-system-xml%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          What other Star Trek series did the main TNG cast show up in?

          Berlina muro

          Berlina aerponto