Magento 2.2.5: explain about how the multi select “available_sort_by” get data The Next CEO of Stack OverflowHow to add multi-select field in magento2 ui formCreate multiselect with source model in UI componentMagento2 ui component multiselect selected options on editMagento 2 Add new field to Magento_User admin formmulti-select image switcher for product configuration. how to do?Magento2 : How disable some specific values in Multi-select UI componentHow to Implement auto text box with multi select in Magento 2 admin?Magento 2.2.5 get the product collection without Stock dataMagento 2.2.5: About Search FullTextMagento 2.2.5: Explain about Position in “Catalog_Category_Product”Magento 2.2.5: How to set checkbox checked with Grid addColumn()Magento 2 ui multi-select preselected valuesmagento 2.2 trying to save multi select value in database

How do I solve this limit?

How to write the block matrix in LaTex?

Too much space between section and text in a twocolumn document

Does the Brexit deal have to be agreed by both Houses?

Opposite of a diet

How to make a variable always equal to the result of some calculations?

Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis

Describing a person. What needs to be mentioned?

What's the point of interval inversion?

How do scammers retract money, while you can’t?

Are there languages with no euphemisms?

WOW air has ceased operation, can I get my tickets refunded?

How can I quit an app using Terminal?

How can I open an app using Terminal?

If I blow insulation everywhere in my attic except the door trap, will heat escape through it?

How to start emacs in "nothing" mode (`fundamental-mode`)

Robert Sheckley short story about vacation spots being overwhelmed

Why were Madagascar and New Zealand discovered so late?

Is it okay to store user locations?

How to use tikz in fbox?

Natural language into sentence logic

How to make a software documentation "officially" citable?

Why didn't Khan get resurrected in the Genesis Explosion?

How do I construct this japanese bowl?



Magento 2.2.5: explain about how the multi select “available_sort_by” get data



The Next CEO of Stack OverflowHow to add multi-select field in magento2 ui formCreate multiselect with source model in UI componentMagento2 ui component multiselect selected options on editMagento 2 Add new field to Magento_User admin formmulti-select image switcher for product configuration. how to do?Magento2 : How disable some specific values in Multi-select UI componentHow to Implement auto text box with multi select in Magento 2 admin?Magento 2.2.5 get the product collection without Stock dataMagento 2.2.5: About Search FullTextMagento 2.2.5: Explain about Position in “Catalog_Category_Product”Magento 2.2.5: How to set checkbox checked with Grid addColumn()Magento 2 ui multi-select preselected valuesmagento 2.2 trying to save multi select value in database










2















I'm looking for an explanation about how the multi-select "available_sort_by" get data.



Like you can see in the image below, they are using UI component to render this multi-select. And I don't understand how did they get the data.



I think they use "available_sort_by" column in somewhere. But I couldn't find them.



enter image description here



So here is the code:




C:xampphtdocsmagentovendormagentomodule-catalogviewadminhtmlui_componentcategory_form.xml




<container name="available_sort_by_group" 

component="Magento_Ui/js/form/components/group" sortOrder="90">
<argument name="data" xsi:type="array">
<item name="type" xsi:type="string">group</item>
<item name="config" xsi:type="array">
<item name="breakLine" xsi:type="boolean">true</item>
<item name="required" xsi:type="boolean">true</item>
</item>
</argument>
<field name="available_sort_by" formElement="multiselect">
<!--<argument name="data" xsi:type="array">-->
<!--<item name="config" xsi:type="array">-->
<!--<item name="source" xsi:type="string">category</item>-->
<!--</item>-->
<!--</argument>-->
<settings>
<additionalClasses>
<class name="admin__field-default">true</class>
</additionalClasses>
<label translate="true">Available Product Listing Sort By</label>
</settings>
</field>
<field name="use_config.available_sort_by" formElement="checkbox">
<settings>
<dataType>boolean</dataType>
<exports>
<link name="checked">ns = $ $.ns , index = available_sort_by :disabled</link>
</exports>
</settings>
<formElements>
<checkbox>
<settings>
<description translate="true">Use All</description>
<valueMap>
<map name="false" xsi:type="boolean">false</map>
<map name="true" xsi:type="boolean">true</map>
</valueMap>
</settings>
</checkbox>
</formElements>
</field>
</container>





Thanks for reading. Have a good day :)



EDIT 1:



So i've try this query in mysql to search which table contain column "available_sort_by", but it return empty.



Here is the query:



SELECT DISTINCT TABLE_NAME 
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ('available_sort_by')
AND TABLE_SCHEMA='magento';


My table named "magento".

And this is the correct query to find which table contain column "X". Because i've try it with my column named "banner_id", and it work perfectly.



EDIT 2:



So i have found some answer and related to it, i'm doing my multi select.

But i dont know why its not run into the toOptionArray() function. But it can go to the __construct() function.



So here is the code:




C:xampphtdocsmagentoappcodeAhtBannerSliderviewadminhtmlui_componentbanner_form.xml




<container name="banner_page_group" component="Magento_Ui/js/form/components/group" sortOrder="40">
<argument name="data" xsi:type="array">
<item name="type" xsi:type="string">group</item>
<item name="options" xsi:type="object">AhtBannerSliderModelPagePageSource</item>
<item name="config" xsi:type="array">
<item name="breakLine" xsi:type="boolean">true</item>
<item name="required" xsi:type="boolean">true</item>
</item>
</argument>
<field name="banner_page" formElement="multiselect">
<settings>
<additionalClasses>
<class name="admin__field-default">true</class>
</additionalClasses>
<label translate="true">Banner Page</label>
</settings>
</field>
<field name="use_config.banner_page" formElement="checkbox">
<settings>
<dataType>boolean</dataType>
<exports>
<link name="checked">ns = $ $.ns , index = banner_page :disabled</link>
</exports>
</settings>
<formElements>
<checkbox>
<settings>
<description translate="true">Use All</description>
<valueMap>
<map name="false" xsi:type="boolean">false</map>
<map name="true" xsi:type="boolean">true</map>
</valueMap>
</settings>
</checkbox>
</formElements>
</field>
</container>



C:xampphtdocsmagentoappcodeAhtBannerSliderModelPagePageSource.php




<?php

namespace AhtBannerSliderModelPage;

use AhtBannerSliderModelResourceModelPageCollectionFactory;

class PageSource implements MagentoFrameworkDataOptionSourceInterface

// protected $pageCollectionFactory;

// public function __construct(CollectionFactory $pageCollectionFactory)
//
// $this->pageCollectionFactory = $pageCollectionFactory;
//

public function toOptionArray()

return [
[
'value' => '1',
'label' => 'Default Level',
],
[
'value' => '2',
'label' => 'Store Level',
],
];


// public function toOptionArray()
//
// $page = $this->pageCollectionFactory->create();
// $options = [];
// foreach ($page as $rows)
// $options[] = [
// 'label' => $rows->getName(),
// 'value' => $rows->getId()
// ];
//
// return $options;
//



I've try both way, and try to debug with xdebug too, but it doesn't go to toOptionArray() function.



EDIT 3:



Solved: I've found the true answer, and this is the perfect code (i thing).



<container name="banner_page_group" component="Magento_Ui/js/form/components/group" sortOrder="40">
<field name="banner_page">
<argument name="data" xsi:type="array">
<item name="type" xsi:type="string">group</item>
<item name="config" xsi:type="array">
<item name="breakLine" xsi:type="boolean">true</item>
<item name="required" xsi:type="boolean">true</item>
<item name="formElement" xsi:type="string">multiselect</item>
<item name="label" xsi:type="string">Banner Page</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="options" xsi:type="object">AhtBannerSliderModelPagePageSource</item>
</argument>
</field>

<!--check box "use all"-->
<field name="use_config.banner_page" formElement="checkbox">
<settings>
<dataType>boolean</dataType>
<exports>
<link name="checked">ns = $ $.ns , index = banner_page :disabled</link>
</exports>
</settings>
<formElements>
<checkbox>
<settings>
<description translate="true">Use All</description>
<valueMap>
<map name="false" xsi:type="boolean">false</map>
<map name="true" xsi:type="boolean">true</map>
</valueMap>
</settings>
</checkbox>
</formElements>
</field>
</container>

<?php

namespace AhtBannerSliderModelPage;

use AhtBannerSliderModelResourceModelPageCollectionFactory;

class PageSource implements MagentoFrameworkOptionArrayInterface

protected $pageCollectionFactory;

public function __construct(CollectionFactory $pageCollectionFactory)

$this->pageCollectionFactory = $pageCollectionFactory;


public function toOptionArray()

$page = $this->pageCollectionFactory->create()->getData();
$options = [];
foreach ($page as $rows)
$options[] = [
'label' => $rows['page_name'],
'value' => $rows['id']
];

return $options;











share|improve this question




























    2















    I'm looking for an explanation about how the multi-select "available_sort_by" get data.



    Like you can see in the image below, they are using UI component to render this multi-select. And I don't understand how did they get the data.



    I think they use "available_sort_by" column in somewhere. But I couldn't find them.



    enter image description here



    So here is the code:




    C:xampphtdocsmagentovendormagentomodule-catalogviewadminhtmlui_componentcategory_form.xml




    <container name="available_sort_by_group" 

    component="Magento_Ui/js/form/components/group" sortOrder="90">
    <argument name="data" xsi:type="array">
    <item name="type" xsi:type="string">group</item>
    <item name="config" xsi:type="array">
    <item name="breakLine" xsi:type="boolean">true</item>
    <item name="required" xsi:type="boolean">true</item>
    </item>
    </argument>
    <field name="available_sort_by" formElement="multiselect">
    <!--<argument name="data" xsi:type="array">-->
    <!--<item name="config" xsi:type="array">-->
    <!--<item name="source" xsi:type="string">category</item>-->
    <!--</item>-->
    <!--</argument>-->
    <settings>
    <additionalClasses>
    <class name="admin__field-default">true</class>
    </additionalClasses>
    <label translate="true">Available Product Listing Sort By</label>
    </settings>
    </field>
    <field name="use_config.available_sort_by" formElement="checkbox">
    <settings>
    <dataType>boolean</dataType>
    <exports>
    <link name="checked">ns = $ $.ns , index = available_sort_by :disabled</link>
    </exports>
    </settings>
    <formElements>
    <checkbox>
    <settings>
    <description translate="true">Use All</description>
    <valueMap>
    <map name="false" xsi:type="boolean">false</map>
    <map name="true" xsi:type="boolean">true</map>
    </valueMap>
    </settings>
    </checkbox>
    </formElements>
    </field>
    </container>





    Thanks for reading. Have a good day :)



    EDIT 1:



    So i've try this query in mysql to search which table contain column "available_sort_by", but it return empty.



    Here is the query:



    SELECT DISTINCT TABLE_NAME 
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE COLUMN_NAME IN ('available_sort_by')
    AND TABLE_SCHEMA='magento';


    My table named "magento".

    And this is the correct query to find which table contain column "X". Because i've try it with my column named "banner_id", and it work perfectly.



    EDIT 2:



    So i have found some answer and related to it, i'm doing my multi select.

    But i dont know why its not run into the toOptionArray() function. But it can go to the __construct() function.



    So here is the code:




    C:xampphtdocsmagentoappcodeAhtBannerSliderviewadminhtmlui_componentbanner_form.xml




    <container name="banner_page_group" component="Magento_Ui/js/form/components/group" sortOrder="40">
    <argument name="data" xsi:type="array">
    <item name="type" xsi:type="string">group</item>
    <item name="options" xsi:type="object">AhtBannerSliderModelPagePageSource</item>
    <item name="config" xsi:type="array">
    <item name="breakLine" xsi:type="boolean">true</item>
    <item name="required" xsi:type="boolean">true</item>
    </item>
    </argument>
    <field name="banner_page" formElement="multiselect">
    <settings>
    <additionalClasses>
    <class name="admin__field-default">true</class>
    </additionalClasses>
    <label translate="true">Banner Page</label>
    </settings>
    </field>
    <field name="use_config.banner_page" formElement="checkbox">
    <settings>
    <dataType>boolean</dataType>
    <exports>
    <link name="checked">ns = $ $.ns , index = banner_page :disabled</link>
    </exports>
    </settings>
    <formElements>
    <checkbox>
    <settings>
    <description translate="true">Use All</description>
    <valueMap>
    <map name="false" xsi:type="boolean">false</map>
    <map name="true" xsi:type="boolean">true</map>
    </valueMap>
    </settings>
    </checkbox>
    </formElements>
    </field>
    </container>



    C:xampphtdocsmagentoappcodeAhtBannerSliderModelPagePageSource.php




    <?php

    namespace AhtBannerSliderModelPage;

    use AhtBannerSliderModelResourceModelPageCollectionFactory;

    class PageSource implements MagentoFrameworkDataOptionSourceInterface

    // protected $pageCollectionFactory;

    // public function __construct(CollectionFactory $pageCollectionFactory)
    //
    // $this->pageCollectionFactory = $pageCollectionFactory;
    //

    public function toOptionArray()

    return [
    [
    'value' => '1',
    'label' => 'Default Level',
    ],
    [
    'value' => '2',
    'label' => 'Store Level',
    ],
    ];


    // public function toOptionArray()
    //
    // $page = $this->pageCollectionFactory->create();
    // $options = [];
    // foreach ($page as $rows)
    // $options[] = [
    // 'label' => $rows->getName(),
    // 'value' => $rows->getId()
    // ];
    //
    // return $options;
    //



    I've try both way, and try to debug with xdebug too, but it doesn't go to toOptionArray() function.



    EDIT 3:



    Solved: I've found the true answer, and this is the perfect code (i thing).



    <container name="banner_page_group" component="Magento_Ui/js/form/components/group" sortOrder="40">
    <field name="banner_page">
    <argument name="data" xsi:type="array">
    <item name="type" xsi:type="string">group</item>
    <item name="config" xsi:type="array">
    <item name="breakLine" xsi:type="boolean">true</item>
    <item name="required" xsi:type="boolean">true</item>
    <item name="formElement" xsi:type="string">multiselect</item>
    <item name="label" xsi:type="string">Banner Page</item>
    <item name="validation" xsi:type="array">
    <item name="required-entry" xsi:type="boolean">true</item>
    </item>
    </item>
    <item name="options" xsi:type="object">AhtBannerSliderModelPagePageSource</item>
    </argument>
    </field>

    <!--check box "use all"-->
    <field name="use_config.banner_page" formElement="checkbox">
    <settings>
    <dataType>boolean</dataType>
    <exports>
    <link name="checked">ns = $ $.ns , index = banner_page :disabled</link>
    </exports>
    </settings>
    <formElements>
    <checkbox>
    <settings>
    <description translate="true">Use All</description>
    <valueMap>
    <map name="false" xsi:type="boolean">false</map>
    <map name="true" xsi:type="boolean">true</map>
    </valueMap>
    </settings>
    </checkbox>
    </formElements>
    </field>
    </container>

    <?php

    namespace AhtBannerSliderModelPage;

    use AhtBannerSliderModelResourceModelPageCollectionFactory;

    class PageSource implements MagentoFrameworkOptionArrayInterface

    protected $pageCollectionFactory;

    public function __construct(CollectionFactory $pageCollectionFactory)

    $this->pageCollectionFactory = $pageCollectionFactory;


    public function toOptionArray()

    $page = $this->pageCollectionFactory->create()->getData();
    $options = [];
    foreach ($page as $rows)
    $options[] = [
    'label' => $rows['page_name'],
    'value' => $rows['id']
    ];

    return $options;











    share|improve this question


























      2












      2








      2








      I'm looking for an explanation about how the multi-select "available_sort_by" get data.



      Like you can see in the image below, they are using UI component to render this multi-select. And I don't understand how did they get the data.



      I think they use "available_sort_by" column in somewhere. But I couldn't find them.



      enter image description here



      So here is the code:




      C:xampphtdocsmagentovendormagentomodule-catalogviewadminhtmlui_componentcategory_form.xml




      <container name="available_sort_by_group" 

      component="Magento_Ui/js/form/components/group" sortOrder="90">
      <argument name="data" xsi:type="array">
      <item name="type" xsi:type="string">group</item>
      <item name="config" xsi:type="array">
      <item name="breakLine" xsi:type="boolean">true</item>
      <item name="required" xsi:type="boolean">true</item>
      </item>
      </argument>
      <field name="available_sort_by" formElement="multiselect">
      <!--<argument name="data" xsi:type="array">-->
      <!--<item name="config" xsi:type="array">-->
      <!--<item name="source" xsi:type="string">category</item>-->
      <!--</item>-->
      <!--</argument>-->
      <settings>
      <additionalClasses>
      <class name="admin__field-default">true</class>
      </additionalClasses>
      <label translate="true">Available Product Listing Sort By</label>
      </settings>
      </field>
      <field name="use_config.available_sort_by" formElement="checkbox">
      <settings>
      <dataType>boolean</dataType>
      <exports>
      <link name="checked">ns = $ $.ns , index = available_sort_by :disabled</link>
      </exports>
      </settings>
      <formElements>
      <checkbox>
      <settings>
      <description translate="true">Use All</description>
      <valueMap>
      <map name="false" xsi:type="boolean">false</map>
      <map name="true" xsi:type="boolean">true</map>
      </valueMap>
      </settings>
      </checkbox>
      </formElements>
      </field>
      </container>





      Thanks for reading. Have a good day :)



      EDIT 1:



      So i've try this query in mysql to search which table contain column "available_sort_by", but it return empty.



      Here is the query:



      SELECT DISTINCT TABLE_NAME 
      FROM INFORMATION_SCHEMA.COLUMNS
      WHERE COLUMN_NAME IN ('available_sort_by')
      AND TABLE_SCHEMA='magento';


      My table named "magento".

      And this is the correct query to find which table contain column "X". Because i've try it with my column named "banner_id", and it work perfectly.



      EDIT 2:



      So i have found some answer and related to it, i'm doing my multi select.

      But i dont know why its not run into the toOptionArray() function. But it can go to the __construct() function.



      So here is the code:




      C:xampphtdocsmagentoappcodeAhtBannerSliderviewadminhtmlui_componentbanner_form.xml




      <container name="banner_page_group" component="Magento_Ui/js/form/components/group" sortOrder="40">
      <argument name="data" xsi:type="array">
      <item name="type" xsi:type="string">group</item>
      <item name="options" xsi:type="object">AhtBannerSliderModelPagePageSource</item>
      <item name="config" xsi:type="array">
      <item name="breakLine" xsi:type="boolean">true</item>
      <item name="required" xsi:type="boolean">true</item>
      </item>
      </argument>
      <field name="banner_page" formElement="multiselect">
      <settings>
      <additionalClasses>
      <class name="admin__field-default">true</class>
      </additionalClasses>
      <label translate="true">Banner Page</label>
      </settings>
      </field>
      <field name="use_config.banner_page" formElement="checkbox">
      <settings>
      <dataType>boolean</dataType>
      <exports>
      <link name="checked">ns = $ $.ns , index = banner_page :disabled</link>
      </exports>
      </settings>
      <formElements>
      <checkbox>
      <settings>
      <description translate="true">Use All</description>
      <valueMap>
      <map name="false" xsi:type="boolean">false</map>
      <map name="true" xsi:type="boolean">true</map>
      </valueMap>
      </settings>
      </checkbox>
      </formElements>
      </field>
      </container>



      C:xampphtdocsmagentoappcodeAhtBannerSliderModelPagePageSource.php




      <?php

      namespace AhtBannerSliderModelPage;

      use AhtBannerSliderModelResourceModelPageCollectionFactory;

      class PageSource implements MagentoFrameworkDataOptionSourceInterface

      // protected $pageCollectionFactory;

      // public function __construct(CollectionFactory $pageCollectionFactory)
      //
      // $this->pageCollectionFactory = $pageCollectionFactory;
      //

      public function toOptionArray()

      return [
      [
      'value' => '1',
      'label' => 'Default Level',
      ],
      [
      'value' => '2',
      'label' => 'Store Level',
      ],
      ];


      // public function toOptionArray()
      //
      // $page = $this->pageCollectionFactory->create();
      // $options = [];
      // foreach ($page as $rows)
      // $options[] = [
      // 'label' => $rows->getName(),
      // 'value' => $rows->getId()
      // ];
      //
      // return $options;
      //



      I've try both way, and try to debug with xdebug too, but it doesn't go to toOptionArray() function.



      EDIT 3:



      Solved: I've found the true answer, and this is the perfect code (i thing).



      <container name="banner_page_group" component="Magento_Ui/js/form/components/group" sortOrder="40">
      <field name="banner_page">
      <argument name="data" xsi:type="array">
      <item name="type" xsi:type="string">group</item>
      <item name="config" xsi:type="array">
      <item name="breakLine" xsi:type="boolean">true</item>
      <item name="required" xsi:type="boolean">true</item>
      <item name="formElement" xsi:type="string">multiselect</item>
      <item name="label" xsi:type="string">Banner Page</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      </item>
      <item name="options" xsi:type="object">AhtBannerSliderModelPagePageSource</item>
      </argument>
      </field>

      <!--check box "use all"-->
      <field name="use_config.banner_page" formElement="checkbox">
      <settings>
      <dataType>boolean</dataType>
      <exports>
      <link name="checked">ns = $ $.ns , index = banner_page :disabled</link>
      </exports>
      </settings>
      <formElements>
      <checkbox>
      <settings>
      <description translate="true">Use All</description>
      <valueMap>
      <map name="false" xsi:type="boolean">false</map>
      <map name="true" xsi:type="boolean">true</map>
      </valueMap>
      </settings>
      </checkbox>
      </formElements>
      </field>
      </container>

      <?php

      namespace AhtBannerSliderModelPage;

      use AhtBannerSliderModelResourceModelPageCollectionFactory;

      class PageSource implements MagentoFrameworkOptionArrayInterface

      protected $pageCollectionFactory;

      public function __construct(CollectionFactory $pageCollectionFactory)

      $this->pageCollectionFactory = $pageCollectionFactory;


      public function toOptionArray()

      $page = $this->pageCollectionFactory->create()->getData();
      $options = [];
      foreach ($page as $rows)
      $options[] = [
      'label' => $rows['page_name'],
      'value' => $rows['id']
      ];

      return $options;











      share|improve this question
















      I'm looking for an explanation about how the multi-select "available_sort_by" get data.



      Like you can see in the image below, they are using UI component to render this multi-select. And I don't understand how did they get the data.



      I think they use "available_sort_by" column in somewhere. But I couldn't find them.



      enter image description here



      So here is the code:




      C:xampphtdocsmagentovendormagentomodule-catalogviewadminhtmlui_componentcategory_form.xml




      <container name="available_sort_by_group" 

      component="Magento_Ui/js/form/components/group" sortOrder="90">
      <argument name="data" xsi:type="array">
      <item name="type" xsi:type="string">group</item>
      <item name="config" xsi:type="array">
      <item name="breakLine" xsi:type="boolean">true</item>
      <item name="required" xsi:type="boolean">true</item>
      </item>
      </argument>
      <field name="available_sort_by" formElement="multiselect">
      <!--<argument name="data" xsi:type="array">-->
      <!--<item name="config" xsi:type="array">-->
      <!--<item name="source" xsi:type="string">category</item>-->
      <!--</item>-->
      <!--</argument>-->
      <settings>
      <additionalClasses>
      <class name="admin__field-default">true</class>
      </additionalClasses>
      <label translate="true">Available Product Listing Sort By</label>
      </settings>
      </field>
      <field name="use_config.available_sort_by" formElement="checkbox">
      <settings>
      <dataType>boolean</dataType>
      <exports>
      <link name="checked">ns = $ $.ns , index = available_sort_by :disabled</link>
      </exports>
      </settings>
      <formElements>
      <checkbox>
      <settings>
      <description translate="true">Use All</description>
      <valueMap>
      <map name="false" xsi:type="boolean">false</map>
      <map name="true" xsi:type="boolean">true</map>
      </valueMap>
      </settings>
      </checkbox>
      </formElements>
      </field>
      </container>





      Thanks for reading. Have a good day :)



      EDIT 1:



      So i've try this query in mysql to search which table contain column "available_sort_by", but it return empty.



      Here is the query:



      SELECT DISTINCT TABLE_NAME 
      FROM INFORMATION_SCHEMA.COLUMNS
      WHERE COLUMN_NAME IN ('available_sort_by')
      AND TABLE_SCHEMA='magento';


      My table named "magento".

      And this is the correct query to find which table contain column "X". Because i've try it with my column named "banner_id", and it work perfectly.



      EDIT 2:



      So i have found some answer and related to it, i'm doing my multi select.

      But i dont know why its not run into the toOptionArray() function. But it can go to the __construct() function.



      So here is the code:




      C:xampphtdocsmagentoappcodeAhtBannerSliderviewadminhtmlui_componentbanner_form.xml




      <container name="banner_page_group" component="Magento_Ui/js/form/components/group" sortOrder="40">
      <argument name="data" xsi:type="array">
      <item name="type" xsi:type="string">group</item>
      <item name="options" xsi:type="object">AhtBannerSliderModelPagePageSource</item>
      <item name="config" xsi:type="array">
      <item name="breakLine" xsi:type="boolean">true</item>
      <item name="required" xsi:type="boolean">true</item>
      </item>
      </argument>
      <field name="banner_page" formElement="multiselect">
      <settings>
      <additionalClasses>
      <class name="admin__field-default">true</class>
      </additionalClasses>
      <label translate="true">Banner Page</label>
      </settings>
      </field>
      <field name="use_config.banner_page" formElement="checkbox">
      <settings>
      <dataType>boolean</dataType>
      <exports>
      <link name="checked">ns = $ $.ns , index = banner_page :disabled</link>
      </exports>
      </settings>
      <formElements>
      <checkbox>
      <settings>
      <description translate="true">Use All</description>
      <valueMap>
      <map name="false" xsi:type="boolean">false</map>
      <map name="true" xsi:type="boolean">true</map>
      </valueMap>
      </settings>
      </checkbox>
      </formElements>
      </field>
      </container>



      C:xampphtdocsmagentoappcodeAhtBannerSliderModelPagePageSource.php




      <?php

      namespace AhtBannerSliderModelPage;

      use AhtBannerSliderModelResourceModelPageCollectionFactory;

      class PageSource implements MagentoFrameworkDataOptionSourceInterface

      // protected $pageCollectionFactory;

      // public function __construct(CollectionFactory $pageCollectionFactory)
      //
      // $this->pageCollectionFactory = $pageCollectionFactory;
      //

      public function toOptionArray()

      return [
      [
      'value' => '1',
      'label' => 'Default Level',
      ],
      [
      'value' => '2',
      'label' => 'Store Level',
      ],
      ];


      // public function toOptionArray()
      //
      // $page = $this->pageCollectionFactory->create();
      // $options = [];
      // foreach ($page as $rows)
      // $options[] = [
      // 'label' => $rows->getName(),
      // 'value' => $rows->getId()
      // ];
      //
      // return $options;
      //



      I've try both way, and try to debug with xdebug too, but it doesn't go to toOptionArray() function.



      EDIT 3:



      Solved: I've found the true answer, and this is the perfect code (i thing).



      <container name="banner_page_group" component="Magento_Ui/js/form/components/group" sortOrder="40">
      <field name="banner_page">
      <argument name="data" xsi:type="array">
      <item name="type" xsi:type="string">group</item>
      <item name="config" xsi:type="array">
      <item name="breakLine" xsi:type="boolean">true</item>
      <item name="required" xsi:type="boolean">true</item>
      <item name="formElement" xsi:type="string">multiselect</item>
      <item name="label" xsi:type="string">Banner Page</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      </item>
      <item name="options" xsi:type="object">AhtBannerSliderModelPagePageSource</item>
      </argument>
      </field>

      <!--check box "use all"-->
      <field name="use_config.banner_page" formElement="checkbox">
      <settings>
      <dataType>boolean</dataType>
      <exports>
      <link name="checked">ns = $ $.ns , index = banner_page :disabled</link>
      </exports>
      </settings>
      <formElements>
      <checkbox>
      <settings>
      <description translate="true">Use All</description>
      <valueMap>
      <map name="false" xsi:type="boolean">false</map>
      <map name="true" xsi:type="boolean">true</map>
      </valueMap>
      </settings>
      </checkbox>
      </formElements>
      </field>
      </container>

      <?php

      namespace AhtBannerSliderModelPage;

      use AhtBannerSliderModelResourceModelPageCollectionFactory;

      class PageSource implements MagentoFrameworkOptionArrayInterface

      protected $pageCollectionFactory;

      public function __construct(CollectionFactory $pageCollectionFactory)

      $this->pageCollectionFactory = $pageCollectionFactory;


      public function toOptionArray()

      $page = $this->pageCollectionFactory->create()->getData();
      $options = [];
      foreach ($page as $rows)
      $options[] = [
      'label' => $rows['page_name'],
      'value' => $rows['id']
      ];

      return $options;








      magento2 multiselect






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 12 mins ago









      Teja Bhagavan Kollepara

      3,01241949




      3,01241949










      asked Aug 11 '18 at 4:25









      fudufudu

      42311




      42311




















          1 Answer
          1






          active

          oldest

          votes


















          2














          OKe. let me show you how to debug ui_component form.
          First, you must know what is: dataSource.



          class MagentoCatalogModelCategoryDataProvider where was define form data to load.



          enter image description here



          Find out these functions.



          1.:



          vendor/magento/module-catalog/Model/Category/DataProvider::getMeta



          2.:
          MagentoCatalogModelCategoryDataProvider::prepareMeta



          3.:
          MagentoCatalogModelCategoryDataProvider::getAttributesMeta



          If you want to modify MetaData of DataProvider you must create a plugin (recommend) |Overide (not recommend) to modify data before or after DataProvider send to UiComponentFactory



          Then let resolve your problem.
          available_sort_by that is category attribute based EAV design you can't find the table has a column named available_sort_by. => Get it from eav_attribute => entity_type_id = 3 and attribute_code='available_sort_by'.



          For EDIT 1:
          You are defined options in the container, please use field instead.






          share|improve this answer

























          • Thanks for reply, so how can i make a multi select have data like them? they use entity but i dont. I just want to make a simple multi select using my table.

            – fudu
            Aug 14 '18 at 4:24











          • Your question related with: magento.stackexchange.com/questions/205830/…

            – HoangHieu
            Aug 14 '18 at 5:11











          • Hi, may i ask why its not run into toOptionArray() function? I implements MagentoFrameworkDataOptionSourceInterface just like what you said. Please help. Thanks you. I've updated the information in edit 2, please check

            – fudu
            Aug 14 '18 at 6:39












          • You are defined options in the container, please use field instead.

            – HoangHieu
            Aug 14 '18 at 7:03











          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%2f238037%2fmagento-2-2-5-explain-about-how-the-multi-select-available-sort-by-get-data%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









          2














          OKe. let me show you how to debug ui_component form.
          First, you must know what is: dataSource.



          class MagentoCatalogModelCategoryDataProvider where was define form data to load.



          enter image description here



          Find out these functions.



          1.:



          vendor/magento/module-catalog/Model/Category/DataProvider::getMeta



          2.:
          MagentoCatalogModelCategoryDataProvider::prepareMeta



          3.:
          MagentoCatalogModelCategoryDataProvider::getAttributesMeta



          If you want to modify MetaData of DataProvider you must create a plugin (recommend) |Overide (not recommend) to modify data before or after DataProvider send to UiComponentFactory



          Then let resolve your problem.
          available_sort_by that is category attribute based EAV design you can't find the table has a column named available_sort_by. => Get it from eav_attribute => entity_type_id = 3 and attribute_code='available_sort_by'.



          For EDIT 1:
          You are defined options in the container, please use field instead.






          share|improve this answer

























          • Thanks for reply, so how can i make a multi select have data like them? they use entity but i dont. I just want to make a simple multi select using my table.

            – fudu
            Aug 14 '18 at 4:24











          • Your question related with: magento.stackexchange.com/questions/205830/…

            – HoangHieu
            Aug 14 '18 at 5:11











          • Hi, may i ask why its not run into toOptionArray() function? I implements MagentoFrameworkDataOptionSourceInterface just like what you said. Please help. Thanks you. I've updated the information in edit 2, please check

            – fudu
            Aug 14 '18 at 6:39












          • You are defined options in the container, please use field instead.

            – HoangHieu
            Aug 14 '18 at 7:03















          2














          OKe. let me show you how to debug ui_component form.
          First, you must know what is: dataSource.



          class MagentoCatalogModelCategoryDataProvider where was define form data to load.



          enter image description here



          Find out these functions.



          1.:



          vendor/magento/module-catalog/Model/Category/DataProvider::getMeta



          2.:
          MagentoCatalogModelCategoryDataProvider::prepareMeta



          3.:
          MagentoCatalogModelCategoryDataProvider::getAttributesMeta



          If you want to modify MetaData of DataProvider you must create a plugin (recommend) |Overide (not recommend) to modify data before or after DataProvider send to UiComponentFactory



          Then let resolve your problem.
          available_sort_by that is category attribute based EAV design you can't find the table has a column named available_sort_by. => Get it from eav_attribute => entity_type_id = 3 and attribute_code='available_sort_by'.



          For EDIT 1:
          You are defined options in the container, please use field instead.






          share|improve this answer

























          • Thanks for reply, so how can i make a multi select have data like them? they use entity but i dont. I just want to make a simple multi select using my table.

            – fudu
            Aug 14 '18 at 4:24











          • Your question related with: magento.stackexchange.com/questions/205830/…

            – HoangHieu
            Aug 14 '18 at 5:11











          • Hi, may i ask why its not run into toOptionArray() function? I implements MagentoFrameworkDataOptionSourceInterface just like what you said. Please help. Thanks you. I've updated the information in edit 2, please check

            – fudu
            Aug 14 '18 at 6:39












          • You are defined options in the container, please use field instead.

            – HoangHieu
            Aug 14 '18 at 7:03













          2












          2








          2







          OKe. let me show you how to debug ui_component form.
          First, you must know what is: dataSource.



          class MagentoCatalogModelCategoryDataProvider where was define form data to load.



          enter image description here



          Find out these functions.



          1.:



          vendor/magento/module-catalog/Model/Category/DataProvider::getMeta



          2.:
          MagentoCatalogModelCategoryDataProvider::prepareMeta



          3.:
          MagentoCatalogModelCategoryDataProvider::getAttributesMeta



          If you want to modify MetaData of DataProvider you must create a plugin (recommend) |Overide (not recommend) to modify data before or after DataProvider send to UiComponentFactory



          Then let resolve your problem.
          available_sort_by that is category attribute based EAV design you can't find the table has a column named available_sort_by. => Get it from eav_attribute => entity_type_id = 3 and attribute_code='available_sort_by'.



          For EDIT 1:
          You are defined options in the container, please use field instead.






          share|improve this answer















          OKe. let me show you how to debug ui_component form.
          First, you must know what is: dataSource.



          class MagentoCatalogModelCategoryDataProvider where was define form data to load.



          enter image description here



          Find out these functions.



          1.:



          vendor/magento/module-catalog/Model/Category/DataProvider::getMeta



          2.:
          MagentoCatalogModelCategoryDataProvider::prepareMeta



          3.:
          MagentoCatalogModelCategoryDataProvider::getAttributesMeta



          If you want to modify MetaData of DataProvider you must create a plugin (recommend) |Overide (not recommend) to modify data before or after DataProvider send to UiComponentFactory



          Then let resolve your problem.
          available_sort_by that is category attribute based EAV design you can't find the table has a column named available_sort_by. => Get it from eav_attribute => entity_type_id = 3 and attribute_code='available_sort_by'.



          For EDIT 1:
          You are defined options in the container, please use field instead.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 14 '18 at 7:17

























          answered Aug 14 '18 at 4:07









          HoangHieuHoangHieu

          746514




          746514












          • Thanks for reply, so how can i make a multi select have data like them? they use entity but i dont. I just want to make a simple multi select using my table.

            – fudu
            Aug 14 '18 at 4:24











          • Your question related with: magento.stackexchange.com/questions/205830/…

            – HoangHieu
            Aug 14 '18 at 5:11











          • Hi, may i ask why its not run into toOptionArray() function? I implements MagentoFrameworkDataOptionSourceInterface just like what you said. Please help. Thanks you. I've updated the information in edit 2, please check

            – fudu
            Aug 14 '18 at 6:39












          • You are defined options in the container, please use field instead.

            – HoangHieu
            Aug 14 '18 at 7:03

















          • Thanks for reply, so how can i make a multi select have data like them? they use entity but i dont. I just want to make a simple multi select using my table.

            – fudu
            Aug 14 '18 at 4:24











          • Your question related with: magento.stackexchange.com/questions/205830/…

            – HoangHieu
            Aug 14 '18 at 5:11











          • Hi, may i ask why its not run into toOptionArray() function? I implements MagentoFrameworkDataOptionSourceInterface just like what you said. Please help. Thanks you. I've updated the information in edit 2, please check

            – fudu
            Aug 14 '18 at 6:39












          • You are defined options in the container, please use field instead.

            – HoangHieu
            Aug 14 '18 at 7:03
















          Thanks for reply, so how can i make a multi select have data like them? they use entity but i dont. I just want to make a simple multi select using my table.

          – fudu
          Aug 14 '18 at 4:24





          Thanks for reply, so how can i make a multi select have data like them? they use entity but i dont. I just want to make a simple multi select using my table.

          – fudu
          Aug 14 '18 at 4:24













          Your question related with: magento.stackexchange.com/questions/205830/…

          – HoangHieu
          Aug 14 '18 at 5:11





          Your question related with: magento.stackexchange.com/questions/205830/…

          – HoangHieu
          Aug 14 '18 at 5:11













          Hi, may i ask why its not run into toOptionArray() function? I implements MagentoFrameworkDataOptionSourceInterface just like what you said. Please help. Thanks you. I've updated the information in edit 2, please check

          – fudu
          Aug 14 '18 at 6:39






          Hi, may i ask why its not run into toOptionArray() function? I implements MagentoFrameworkDataOptionSourceInterface just like what you said. Please help. Thanks you. I've updated the information in edit 2, please check

          – fudu
          Aug 14 '18 at 6:39














          You are defined options in the container, please use field instead.

          – HoangHieu
          Aug 14 '18 at 7:03





          You are defined options in the container, please use field instead.

          – HoangHieu
          Aug 14 '18 at 7:03

















          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%2f238037%2fmagento-2-2-5-explain-about-how-the-multi-select-available-sort-by-get-data%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

          Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

          How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2

          Nissan Patrol Зміст Перше покоління — 4W60 (1951-1960) | Друге покоління — 60 series (1960-1980) | Третє покоління (1980–2002) | Четверте покоління — Y60 (1987–1998) | П'яте покоління — Y61 (1997–2013) | Шосте покоління — Y62 (2010- ) | Посилання | Зноски | Навігаційне менюОфіційний український сайтТест-драйв Nissan Patrol 2010 7-го поколінняNissan PatrolКак мы тестировали Nissan Patrol 2016рвиправивши або дописавши її