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 to be diplomatic in refusing to write code that breaches the privacy of our users

Was a professor correct to chastise me for writing "Prof. X" rather than "Professor X"?

Can a caster that cast Polymorph on themselves stop concentrating at any point even if their Int is low?

What can we do to stop prior company from asking us questions?

Opposite of a diet

What does this shorthand mean?

Why do remote companies require working in the US?

Where to find order of arguments for default functions

Go Pregnant or Go Home

Why were Madagascar and New Zealand discovered so late?

Visit to the USA with ESTA approved before trip to Iran

Text adventure game code

How can I get through very long and very dry, but also very useful technical documents when learning a new tool?

What makes a siege story/plot interesting?

Robert Sheckley short story about vacation spots being overwhelmed

How do I solve this limit?

Why do professional authors make "consistency" mistakes? And how to avoid them?

Does it take more energy to get to Venus or to Mars?

Is it safe to use c_str() on a temporary string?

How to get regions to plot as graphics

Trouble understanding the speech of overseas colleagues

Describing a person. What needs to be mentioned?

I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin

Whats the best way to handle refactoring a big file?



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 11 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

          Magento 2 disable Secret Key on URL's from terminal The Next CEO of Stack OverflowMagento 2 Shortcut/GUI tool to perform commandline tasks for windowsIn menu add configuration linkMagento oAuth : Generating access token and access secretMagento 2 security key issue in Third-Party API redirect URIPublic actions in admin controllersHow to Disable Cache in Custom WidgetURL Key not changing in Magento 2Product URL Key gets deleted when importing custom options - Magento 2Problem with reindex terminalMagento 2 - bin/magento Commands not working in Cpanel Terminal

          Aasi (pallopeli) Navigointivalikko