- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2020
06:32 AM
09-04-2020
06:32 AM
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
Labels:
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2020
11:50 PM
09-09-2020
11:50 PM
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
Find helpful ?Consider Giving Kudos to this post.
Problem solved? ClickAccept as Solution!
Problem solved? ClickAccept as Solution!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2020
01:22 AM
09-10-2020
01:22 AM
Re: Multi select list of attribute to checkbox
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 ..
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2023
03:51 AM
02-24-2023
03:51 AM
Re: Multi select list of attribute to checkbox
@piyush_khandelw if your have done this can you provide a solution here
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023
10:14 AM
03-06-2023
10:14 AM
Re: Multi select list of attribute to checkbox
<field name="size"> <argument name="data" xsi:type="array"> <item name="label" xsi:type="string" translate="true">Cuisines</item> <item name="options" xsi:type="object">Vendor\Model_name\Model\Config\Checkboxzise</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">size</item> </item> </argument> </field>
Vendor\<Module_name>\Model\Config\Checkboxsize
In this class to return array which you want to show in checkbox option
for Example
return [['value' => "xs", 'label' => __('XS')], ['value' => "s", 'label' => __('S')], ['value' => "m", 'label' => __('M')] ];