0

I'm using Modifier class to disable some ui components on admin screen. But when I implemented modifyMeta() method, some of the needed ui components not included in the metadata array (eg: gallery) So how can I modify these component? T4R.

public function modifyMeta(array $meta)
{
    $canEditApplication = ObjectManager::getInstance()->get(AuthorizationInterface::class)->isAllowed('ScPortal_Backend::application_save');

    if (!$canEditApplication) {
        $meta['product-scheduler']['children']['ew_schedule_start_date']['arguments']['data']['config'] = [
            'disabled' => true
        ];
        $meta['product-scheduler']['children']['ew_schedule_end_date']['arguments']['data']['config'] = [
            'disabled' => true
        ];
        $meta['product-scheduler']['children']['ew_schedule_status']['arguments']['data']['config'] = [
            'disabled' => true
        ];

        $meta['gallery']['arguments']['data']['config'] = [
            'componentType' => 'container',
            'disabled' => true
        ];
    }

1 Answer 1

0

Try this code. hope it helps you.

//use Magento\Framework\Stdlib\ArrayManager;
public function modifyMeta(array $meta)
    {
        $attribute = 'your attribute code'; 

        $path = $this->arrayManager->findPath($attribute, $meta, null, 'children');
        $meta = $this->arrayManager->set(
            "{$path}/arguments/data/config/disabled",
            $meta,
            true
        );
        return $meta;
    }
2
  • thanks but the attribute on screen doesn't exist in the $meta array so i can't find it
    – namikaze
    Commented Oct 20, 2020 at 6:33
  • which attribute you want to disable? if you want to disable gallery attribute just pass 'gallery' to $attribute variable. you can search attribute code to store->attributes->product
    – Ronak
    Commented Oct 20, 2020 at 6:48

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.