0

I have a custom module in admin with it's own admin page controller and ui-form with a variety of fields.

One of these fields I want to be a 'checkboxset'. When I set the formElement value to that it shows properly as a list of checkboxes and I can select these and save these with some controller code that is saving the rest of the form fields (some input's and multiselects).

However, when the admin page reloads it does not show the saved values.

All the checkboxes start as unchecked.

I checked and the data is being saved in the database. And I can see in the page source that previously saved values are in the data_source.

I also tried switching it from a 'checkboxset' to a 'multiselect' and it worked without issue.

The code for the field is below:

<field name="condition_checklist" formElement="checkboxset" sortOrder="140">
  <argument name="data" xsi:type="array">
    <item name="options" xsi:type="object">Ose\Tradein\Model\Source\ConditionChecklist</item>
    <item name="config" xsi:type="array">
      <item name="source" xsi:type="string">Tradein</item>
      <item name="additionalInfo" xsi:type="string">You must tick all of the boxes</item>
    </item>
  </argument>
  <settings>
    <dataType>text</dataType>
    <label translate="true">Condition Checklist</label>
    <dataScope>condition_checklist</dataScope>
    <validation>
      <rule name="required-entry" xsi:type="boolean">false</rule>
    </validation>
  </settings>
</field>

I did a search of core magento to see if I could find an example of this field type being used but the only references to 'checkboxset' I could find were in test or when it's declared in magento-ui

2
  • How are you storing the selected values in the database? In what format? – Abdul Samad Abbasi Feb 26 at 6:26
  • the values are stored in a comma seperated id format (eg. 1,6,8) in a text type column. For the multiselect fields this works. – Typhado Feb 28 at 22:31

Your Answer

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

Browse other questions tagged or ask your own question.