0

I have begun creating a custom form for magento, this form include the elemenet checkboxset as documented here... https://devdocs.magento.com/guides/v2.4/ui_comp_guide/components/ui-checkboxset.html

My form also includes other Fields.

In my controller I get the value of the fields using $this->getRequest()->getParams(), this works fine untill I introduce the checkboxset, now I am only able to retrieve the values of the checkboxes and no longer the values of all other fields.

It seems I can only have Fields or Checkboxset and not both together, doesn anyone have any idea what I may be doing wrong? I have pasted the code for my field-set below.

<fieldset name="invoice_details">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="collapsible" xsi:type="boolean">false</item>
            <item name="label" xsi:type="string" translate="true">Supplier Payment</item>
            <item name="sortOrder" xsi:type="number">10</item>
        </item>
    </argument>
    
    <checkboxset name="checkboxset_example">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="additionalInfo" xsi:type="string">Additional information</item>
            </item>
        </argument>
        <settings>
            <label translate="true">Checkboxset Component Example</label>
            <options>
                <option name="0" xsi:type="array">
                    <item name="value" xsi:type="number">1</item>
                    <item name="label" xsi:type="string" translate="true">Option #1</item>
                </option>
                <option name="1" xsi:type="array">
                    <item name="value" xsi:type="number">2</item>
                    <item name="label" xsi:type="string" translate="true">Option #2</item>
                </option>
                <option name="2" xsi:type="array">
                    <item name="value" xsi:type="number">3</item>
                    <item name="label" xsi:type="string" translate="true">Option #3</item>
                </option>
            </options>
        </settings>
    </checkboxset>

    <field name="bank_reference">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="dataType" xsi:type="string">text</item>
                <item name="label" xsi:type="string" translate="true">Bank Reference</item>
                <item name="formElement" xsi:type="string">input</item>
                <item name="source" xsi:type="string">bank_reference</item>
                <item name="dataScope" xsi:type="string">bank_reference</item>
                <item name="validation" xsi:type="array">
                    <item name="required-entry" xsi:type="boolean">true</item>
                    <item name="alpha-num" xsi:type="boolean">true</item>
                </item>
            </item>
        </argument>
    </field>

</fieldset>

Thanks,

Dan.

1 Answer 1

0

The issue was that I had not provided a dataScope attribute, this needs to be added to the config element of the checkboxset.

            <item name="config" xsi:type="array">
                <item name="dataScope" xsi:type="string">invoices</item>
                <item name="label" xsi:type="string" translate="true">Included Invoices</item>
            </item>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.