cancel
Showing results for 
Search instead for 
Did you mean: 

Multi select list of attribute to checkbox

Highlighted

Multi select list of attribute to checkbox

Hi,

I need to change the multi select attribute into checkbox so admin can easily checked attribute i am using magento 2.3

2 REPLIES 2
Highlighted

Re: Multi select list of attribute to checkbox

* You can use
<item name="formElement" xsi:type="string">checkboxset</item>
  
Multiselect/checkboxset both return the field value in text format, you need to make changes only to the presentation layer for the attribute. There is a formElement checkbox set in magento which will fulfill your requirement. check the code below
 
<field name="cuisines">
    <argument name="data" xsi:type="array">
        <item name="label" xsi:type="string" translate="true">Cuisines</item>
        <item name="options" xsi:type="object">Ricky\Hoteladvnce\Model\Config\Checkboxcuisines</item>
        <item name="config" xsi:type="array">
            <item name="label" xsi:type="string" translate="true">cuisines</item>
            <item name="visible" xsi:type="boolean">true</item>
            <item name="dataType" xsi:type="string">text</item>
            <item name="formElement" xsi:type="string">checkboxset</item>
            <item name="source" xsi:type="string">module</item>
            <item name="multiple" xsi:type="boolean">true</item>
            <item name="dataScope" xsi:type="string">cuisines</item>
        </item>
    </argument>
</field>
You need to proivde checkbox array to display options in
Ricky\Hoteladvnce\Model\Config\Checkboxcuisines.php
 
public function toOptionArray()
    {
        return [['value' => "mx", 'label' => __('Mexican')], 
                ['value' => "it", 'label' => __('Italian')], 
                ['value' => "in", 'label' => __('Indian')]
               ];
    }
 
Outpurt
test.png
 
 
Find helpful ?Consider Giving Kudos to this post.
Problem solved? ClickAccept as Solution!
Highlighted

Re: Multi select list of attribute to checkbox

hi @Kapil_Thakur 

 

Thank for reply .... but  my question about product page where the attribute (product attribute) with multi select option i need to convert that multi-select in checkbox so user can easily check more then one attribute without ctrl+click to select attribute ..