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

% symbol leads to superlong (forever?) compilations

Whats the best way to handle refactoring a big file?

How easy is it to start Magic from scratch?

Why did we only see the N-1 starfighters in one film?

Increase performance creating Mandelbrot set in python

What happens if you roll doubles 3 times then land on "Go to jail?"

Anatomically Correct Mesopelagic Aves

Rotate a column

What do "high sea" and "carry" mean in this sentence?

MAZDA 3 2006 (UK) - poor acceleration then takes off at 3250 revs

How do we know the LHC results are robust?

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

What is the purpose of the Evocation wizard's Potent Cantrip feature?

How can I open an app using Terminal?

What makes a siege story/plot interesting?

How to write papers efficiently when English isn't my first language?

How long to clear the 'suck zone' of a turbofan after start is initiated?

Why is there a PLL in CPU?

Go Pregnant or Go Home

The King's new dress

Where to find order of arguments for default functions

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

Text adventure game code

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



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

          “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

          How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

          夢乃愛華...