1

I'm having a trouble with UIComponent. Being precise it's a checkbox.

I'm sure it takes true as a value, but it doesn't appear as a checked one.

So it's propably something wrong with my structure.

'is_active' => [
                'arguments' => [
                    'data' => [
                        'config' => [
                            'label' => __('Active'),
                            'dataType' => 'boolean',
                            'formElement' => 'checkbox',
                            'componentType' => 'field',
                            'sortOrder' => 10,
                            'dataScope' => 'is_active',
                            'prefer' => 'toggle',
                            'valueMap' => [
                                'false' => 0,
                                'true' => 1
                            ],
                            'visible' => 1,
                        ]
                    ]
                ]
            ],
  • Are passing value to the ui-component by its data provider? If yes then share your code of data provider – Ashish Raj Nov 22 '17 at 6:07
0

I'm not sure if I understand you when you say: "it doesn't appear as checked one."

If you just want it to be checked as default, add this in config:

'default' => 1,

If that's not the case, please elaborate you question.

  • I tried everything including your answer. Gave up and used select instead. – Ydrus Nov 20 '17 at 14:25
0

To this day I have no idea what was wrong with a checkbox. Decided to use Yesno select instead.

 /**
 * @var \Magento\Config\Model\Config\Source\Yesno
 */
protected $yesno;


/**
 * Store constructor.
 * @param \Magento\Config\Model\Config\Source\Yesno $yesno
 */

 public function __construct(
\Magento\Config\Model\Config\Source\Yesno $yesno
) {
    $this->yesno = $yesno;
}

...
 'children' => [
            'is_active' => [
                'arguments' => [
                    'data' => [
                        'options' => $this->yesno->toOptionArray(),
                        'config' => [
                            'label' => __('Active'),
                            'dataType' => 'boolean',
                            'formElement' => 'select',
                            'componentType' => 'field',
                            'sortOrder' => 10,
                            'dataScope' => 'is_active',
                            'visible' => 1,
                            'default' => 0,
                        ]
                    ]
                ]
            ],
...

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.