Skip to content

Unable to enter + character in widget content #16234

@molovo

Description

@molovo

Preconditions

  1. Magento version: 2.2.3 (I haven't yet tested other versions)

Steps to reproduce

  1. Create a widget with a parameter of xsi:type="text" or xsi:type="block" with a textarea block
  2. Add the widget to the content of a CMS page
  3. Enter a string containing a + character into the text field of the widget

Expected result

  1. The + character appears on the rendered page

Actual result

  1. The + character is missing from the rendered page. It is still present in the page content stored in the database, and appears when editing the widget.

Example widget parameter declaration

<parameter name="title" xsi:type="text" visible="true">
  <label translate="true">Title</label>
</parameter>

<parameter name="content" xsi:type="block" required="true" visible="true">
  <label translate="true">Content</label>

  <block class="<vendor>\<module>\Block\Adminhtml\Widget\TextArea"/>
</parameter>

Example TextArea block

<?php

namespace <vendor>\<module>\Block\Adminhtml\Widget;

use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Form\Element;
use Magento\Cms\Model\Wysiwyg\Config;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Data\Form\Element\Factory;

class TextArea extends Element
{
    protected $_elementFactory;

    /**
     * @param Context $context
     * @param Factory $elementFactory
     * @param array   $data
     * @param Config  $config
     */
    public function __construct(Context $context, Factory $elementFactory, Config $config, array $data = [])
    {
        $this->_elementFactory = $elementFactory;
        $this->_wysiwygConfig  = $config;
        parent::__construct($context, $data);
    }

    /**
     * Prepare chooser element HTML.
     *
     * @param AbstractElement $element Form Element
     *
     * @return AbstractElement
     */
    public function prepareElementHtml(AbstractElement $element)
    {
        $input = $this->_elementFactory->create('textarea', ['data' => $element->getData()])
            ->setId($element->getId())
            ->setClass('widget-option input-textarea admin__control-text')
            ->setForm($element->getForm());

        if ($element->getRequired()) {
            $input->addClass('required-entry');
        }

        $element->setData('after_element_html', $input->getElementHtml());

        return $element;
    }
}

Metadata

Metadata

Assignees

Labels

Component: WidgetFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasegood first issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions