1

I am a bit of a lost as to handling checkboxes (a group of them) for a custom form, made as a UI Component.

On the form, they look as if they are unchecked, but if I click them then it reacts normally, but the "Pencil" indicator does not show up on the tab button on the left of the admin page until I unchecked the checkbox that it shows this part of the form has been changed. Furthermore, if I submit the form without changing the checkboxes then the POST data shows they are checked with their correct values. It is only when I "check" then "uncheck" the boxes that the POST value does NOT include the fields.Please reply me if anyone know.

Vendor/Module/view/adminhtml/ui_component/location_listing.xml

<fieldset name="features">
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
 <item name="label" xsi:type="string" translate="true">Features</item>
 </item>
 </argument>
 <field name="feature_discovery">
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
 <item name="label" xsi:type="string">Discovery Center</item>
 <item name="visible" xsi:type="boolean">true</item>
 <item name="dataType" xsi:type="string">text</item>
 <item name="formElement" xsi:type="string">checkbox</item>
 <item name="value" xsi:type="number">1</item>
 <item name="checked" xsi:type="boolean">false</item>
 <item name="source" xsi:type="string">features</item>
 </item>
 </argument>
 </field>
 <field name="feature_classes">
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
 <item name="label" xsi:type="string">Classes</item>
 <item name="visible" xsi:type="boolean">true</item>
 <item name="dataType" xsi:type="string">text</item>
 <item name="formElement" xsi:type="string">checkbox</item>
 <item name="value" xsi:type="number">2</item>
 <item name="checked" xsi:type="boolean">false</item>
 <item name="source" xsi:type="string">features</item>
 </item>
 </argument>
 </field>
 <field name="feature_outlet">
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
 <item name="label" xsi:type="string">Outlet Center</item>
 <item name="visible" xsi:type="boolean">true</item>
 <item name="dataType" xsi:type="string">text</item>
 <item name="formElement" xsi:type="string">checkbox</item>
 <item name="value" xsi:type="number">3</item>
 <item name="checked" xsi:type="boolean">false</item>
 <item name="source" xsi:type="string">features</item>
 </item>
 </argument>
 </field>
</fieldset>

Before any interaction

After checking an "unchecked" box

After unchecked a checked box

asked Sep 28, 2018 at 12:10

1 Answer 1

2

I went from:

<field name="feature_classes">
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
 <item name="label" xsi:type="string">Classes</item>
 <item name="visible" xsi:type="boolean">true</item>
 <item name="dataType" xsi:type="string">text</item>
 <item name="formElement" xsi:type="string">checkbox</item>
 <item name="value" xsi:type="number">2</item>
 <item name="checked" xsi:type="boolean">false</item>
 <item name="source" xsi:type="string">features</item>
 </item>
 </argument>
</field>

To

<field name="feature_classes">
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
 <item name="label" xsi:type="string">Classes</item>
 <item name="visible" xsi:type="boolean">true</item>
 <item name="dataType" xsi:type="string">text</item>
 <item name="formElement" xsi:type="string">checkbox</item>
 <item name="valueMap" xsi:type="array">
 <item name="true" xsi:type="number">1</item>
 <item name="false" xsi:type="number">0</item>
 </item>
 <item name="source" xsi:type="string">features</item>
 </item>
 </argument>
 </field>

Basically replacing the value and checked items for a valueMap item.

answered Oct 3, 2018 at 20:20

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.