I have created an option on my custom widget that uses WYSIWYG. All works fine with the depends in as far as if it matches it shows and if it doesn't it hides the field. However, if it does not match the label still shows.


<?xml version="1.0" ?>
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd">
    <widget class="Vendor\Module\Block\Widget\Content" id="Vendor_Module">
            <!-- Content Type -->
            <parameter name="dropdown" sort_order="20" visible="true" required="true" xsi:type="select">
                <label>Type of content</label>
                    <option name="option1" value="option1" selected="true">
                        <label>option 1</label>
                    <option name="option2" value="option2">
                        <label>option 2</label>
                    <option name="option3" value="option3">
                        <label>option 3</label>
            <!-- First Block -->
            <parameter name="content" sort_order="20" visible="true" required="false" xsi:type="block">
                <block class="Vendor\Module\Block\Widget\Editor" />
            <!-- Second Block -->
            <parameter name="second_content" sort_order="20" visible="true" required="false" xsi:type="block">
                <label>Second Block</label>
                    <parameter name="dropdown" value="option3"/>
                <block class="Vendor\Module\Block\Widget\Editor" />



namespace Vendor\Module\Block\Widget;

class Editor extends \Magento\Backend\Block\Widget\Form\Element 

     * @var \Magento\Cms\Model\Wysiwyg\Config
    protected $_wysiwygConfig;

     * @var Factory
    protected $_factoryElement;

     * @param Factory $factoryElement
     * @param CollectionFactory $factoryCollection
     * @param array $data
    public function __construct(
    \Magento\Backend\Block\Template\Context $context, \Magento\Framework\Data\Form\Element\Factory $factoryElement, \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig, $data = []
    ) {
        $this->_factoryElement = $factoryElement;
        $this->_wysiwygConfig = $wysiwygConfig;
        parent::__construct($context, $data);

     * Prepare chooser element HTML
     * @param \Magento\Framework\Data\Form\Element\AbstractElement $element Form Element
     * @return \Magento\Framework\Data\Form\Element\AbstractElement
    public function prepareElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) {
        $editor = $this->_factoryElement->create('editor', ['data' => $element->getData()])

        if ($element->getRequired()) {

                'after_element_html', $this->_getAfterElementHtml() . $editor->getElementHtml()

        return $element;

     * @return string
    protected function _getAfterElementHtml() {
        $html = <<<HTML
        .admin__field-control.control .control-value {
            display: none !important;

        return $html;


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.