0

I'm trying to add extra configuration options to all widget configuration/edit screens, not just cms_static_block for example, but all available widget types.

I've managed to add an additional tab (under 'widget options') by looking at how magento itself does it, but how the forms/fields themselves are added is beyond me at this point.

There is an _addField($parameter) function in the class that adds the extra tab(which extends \Magento\Widget\Block\Adminhtml\Widget\Options and implements \Magento\Backend\Block\Widget\Tab\TabInterface), and shorting it (return false;) gives me an empty form (instead of the form of the previous tab) but I'm pretty sure I shouldn't mess with that. Instead I'm pretty sure I should be creating templates and overriding classes somewhere else.

Maybe someone can point me in the right direction?

Thanks in advance.

1 Answer 1

0

Tuns out I had to override Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Tab\Properties.

Options.php:

<?php

namespace Vendor\Module\Block\Adminhtml\Widget;

use Magento\Framework\DataObject;
use Vendor\Module\Service\HTTPService;

class Options extends \Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Tab\Properties {


public function addFields(){
    parent::addFields();

    $fieldset = $this->getMainFieldset();

    $checked = $this->getChecked($this->getData());

    $fieldset->addField(
        $this->getMainFieldsetHtmlId() . '_' . 'ven_service',
        'checkboxes',
        [
            'name' => __('parameters[ven_service][]'),
            'label' => __('Service'),
            'title' => __('Service'),
            'values' => $this->populateValues(),
            'checked' => $checked
        ]
    );       

    return $this;
}

}

adminhtml/di.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Tab\Properties" type="Vendor\Module\Block\Adminhtml\Widget\Options"/>
</config>

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.