Bhaveshpp

Professional Magento Developr - Healp eachother to grow

Magento2: Ui component

05 Oct 2021 » magento2, ui-component

use async

    require(['uiRegistry'],  function(registry){ 
        registry.async('swissup-address-fields.buy_as_company')(function (buyAsCompany ) { 
            buyAsCompany.value.subscribe(function (value) {
                registry.get('swissup-address-fields.company').visible(value);
                registry.get('swissup-address-fields.ico').visible(value);
                registry.get('swissup-address-fields.dic').visible(value);
                registry.get('swissup-address-fields.vat_id').visible(value);
            });
        });
    });

$config[$field->getAttributeCode()] = [
    'label' => $field->getStoreLabel($storeId),
    'config' => [
        'customScope' => 'custom_attributes',
        'template' => 'ui/form/field',
        'elementTmpl' => $this->helper->getFieldTemplate($field),
        'multiple' => $field->getFrontendInput() == 'multiselect',
        'additionalClasses' => $this->getAdditionalClasses($field)
    ],
    'validation' => $this->getFieldValidation($field),
    'options' => $this->getFieldOptions($field),
    'component' => $this->helper->getFieldUiComponent($field),
    'provider' => 'swissup' . ucfirst(static::ENTITY_TYPE) . 'Provider',
    'caption' => __('Please select'),
    'dataScope' => $this->getFieldDataScope($field),
    'sortOrder' => $field->getSortOrder(),
    'visible' => $field->getIsVisible() ? true : false,
    'value' => $this->getFieldValue($field),
    'imports' => [
        'visible' => '${ $.parentName }.buy_as_company:value'
    ]
];