Alcony

Otwarta Społeczność

Magento 2 hide form tab
Magento

Magento 2 – How to Hide Form Tab

To hide form tab You can use isComponentVisible() method inside Fieldset Class.

<?php

declare(strict_types=1);

namespace Custom\Custom\Ui\Component\Form;

use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\ComponentVisibilityInterface;
use Magento\Ui\Component\Form\Fieldset;

/**
 * Class Fieldset
 * @package Custom\Custom\Ui\Component\Form
 */
class CustomFieldset extends Fieldset implements ComponentVisibilityInterface
{
    /**
     * CustomFieldset constructor.
     * @param ContextInterface $context
     * @param array $components
     * @param array $data
     */
    public function __construct(
        ContextInterface $context,
        array $components = [],
        array $data = []
    ) {
        $this->context = $context;

        parent::__construct($context, $components, $data);
    }

    /**
     * @return bool
     */
    public function isComponentVisible(): bool
    {
        $visible = //add logic
        return (bool)$visible;
    }
}

It’s important to change default Fieldset class in Your ui_component .xml file like so:

<fieldset name="custom" sortOrder="30" class="Custom\Custom\Ui\Component\Form\CustomFieldset">

https://magento.stackexchange.com/a/276461

Udostępnij:

LEAVE A RESPONSE

Your email address will not be published. Required fields are marked *

CEO alcony.pl CEO jaksmakowalo.pl PHP Developer at Advox.pl
error

Znajdziesz nas również tutaj: