2

I'm attempting to build a widget that allows the customer to build product tabs.

I'm using conditions to allow the user to filter on products (using the core CatalogWidget conditions block)

Widget.xml:

<parameter name="condition_1" xsi:type="conditions" visible="true" required="true" sort_order="10" class="Magento\CatalogWidget\Block\Product\Widget\Conditions">
    <label translate="true">Conditions</label>
</parameter>
<parameter name="condition_2" xsi:type="conditions" visible="true" required="true" sort_order="10" class="Magento\CatalogWidget\Block\Product\Widget\Conditions">
    <label translate="true">Conditions</label>
</parameter>

When I add 2 conditions like this to my widget.xml, I receive the following error in system.log:

[2019-03-26 09:44:55] main.CRITICAL: An element with a "conditions__1__type" ID already exists. [] []

I've attempted to amend the elementId using a custom Conditions class and amending the output html like:

public function getInputHtml()
{
    $this->input = $this->elementFactory->create('text');
    $this->input->setRule($this->rule)->setRenderer($this->conditions);
    $this->input->setId($this->element->getId());
    return $this->input->toHtml();
}

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.