0

I'm building a feature where I need to render checkboxes for a set of comma-separated values in a column.

Here's my existing code:

protected function fillModifierMeta()
    {
        return [
            'id' => $this->getTextColumn('id', false, 'Product ID', 10),
            'product_sku' => $this->getTextColumn('product_sku', false, 'Product SKU', 20),
            'product_name' => $this->getTextColumn('product_name', false, 'Product Name', 30),
            'product_supplier_sku' => $this->getTextColumn('product_supplier_sku', false, 'Supplier SKU', 40),
            'available_qty' => $this->getTextColumn('available_qty', false, 'Available Qty', 50),
            'received_qty' => [
                'arguments' => [
                    'data' => [
                        'config' => [
                            'dataType' => Form\Element\DataType\Number::NAME,
                            'formElement' => Form\Element\Input::NAME,
                            'componentType' => Form\Field::NAME,
                            'dataScope' => 'received_qty',
                            'label' => __('Receive Qty'),
                            'fit' => true,
                            'additionalClasses' => 'admin__field-small',
                            'sortOrder' => 60,
                            'validation' => [
                                'validate-number' => true,
                                'validate-greater-than-zero' => true,
                                'required-entry' => true,
                            ],
                        ],
                    ],
                ],
            ],
            'actionDelete' => [
                'arguments' => [
                    'data' => [
                        'config' => [
                            'additionalClasses' => 'data-grid-actions-cell',
                            'componentType' => 'actionDelete',
                            'dataType' => Form\Element\DataType\Text::NAME,
                            'label' => __('Actions'),
                            'sortOrder' => 70,
                            'fit' => true,
                        ],
                    ],
                ],
            ]
        ];
    }

Which renders it like this: enter image description here

Now, I want to add a field to this called barcodes which contains value such as EG6F2,A4GT5,EF58T,Y1W3R. I want to render these as selectable checkboxes in the column.

Is there a way to achieve this?

1
  • Can you share the whole code from where you called fillModifierMeta function May 19, 2023 at 6:51

1 Answer 1

0

I found how to accomplish this. If anyone is interested this is how you can do it:

'barcodes' => [
                'arguments' => [
                    'data' => [
                        'config' => [
                            'dataType' => Form\Element\DataType\Text::NAME,
                            'formElement' => Form\Element\CheckboxSet::NAME,
                            'options' => [
                                ['label' => 'test', 'value' => 'test'],
                                ['label' => 'test', 'value' => 'test1']
                            ],
                            'componentType' => Form\Field::NAME,
                            'dataScope' => 'barcodes',
                            'label' => __('Barcodes'),
                            'fit' => true,
                            'additionalClasses' => 'admin__field-small',
                            'sortOrder' => 70,
                            'validation' => [
                                'required-entry' => true
                            ],
                        ],
                    ],
                ],
            ]

Your Answer

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

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