Closed VLCSolutions closed 7 years ago
It looks like it is being double escaping when being populated into the form. Are you using JavaScript when populating the form fields, or PHP code? There seems to be one too many layers of escaping going on.
Edit: Sorry, I need to read more carefully. I just realized you are talking about our forms in Admin panel. I will go have a quick look.
I suspect this is related to the file app/code/Magento/Config/view/adminhtml/templates/system/config/form/field/array.phtml. I am guessing we are double escaping on the way out, which would be a bug. I am going to leave as a bug for the Engineering team more familiar with this code.
@alankent bug label not assigned? can i expect the solution before magento2 release?
@alankent Magento2 Community and enterprise editions released but not yet resolved my bug!
Not all bugs were fixed by GA, as you have noticed. We will continue to burn down bugs. The PMs and engineers continually review the bug backlog to set the priority relative to other issues. If you believe this is really important (it is clearly a bug - no question there), feel free to explain why (and get some others to agree). It is not always easy for the team to rate bugs relative to each other - they are all important. We just need to work out which is more important.
@alankent We are developing an extension and this bug relates to extension. Once we complete extension we are planning to implement this extension in our client magento2 project. So request you to consider this bug as important and provide feasible solution
Internal ticket is created MAGETWO-51643.
@VLCSolutions, I am not able to reproduce the issue on the latest code. Could you please re-check.
@MaxSavich @alankent @KrystynaKabannyk
You can execute at any version (Magento 2.x.x).
Please copy and paste below code in your module and execute it to reproduce the issue.
/app/code/Learning/Test/Block/Adminhtml/Form/Field/Config/Create/Configbody.php
<?php
namespace Learning\Test\Block\Adminhtml\Form\Field\Config\Create;
class Configbody extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
{
protected $_attributesRenderer;
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
array $data = []
) {
parent::__construct($context, $data);
}
/**
* Initialise form fields
*
* @return void
*/
protected function _construct()
{
parent::_construct();
}
protected function _prepareToRender()
{
$this->addColumn('element', ['label' => __('Element'), 'style' => 'width:250px']
);
$this->addColumn('constant', ['label' => __('Constant'), 'style' => 'width:150px']);
$this->_addAfter = true;
$this->_addButtonLabel = __('Add');
}
}
/app/code/Learning/Test/etc/adminhtml/system.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="custom" translate="label" sortOrder="0">
<label>Test Configuration</label>
</tab>
<section id="custom_config" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Configuration</label>
<tab>custom</tab>
<resource>Learning_Test::config_custom</resource>
<group id="custom_config_group" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Test Config Saving</label>
<field id="custom_config_body" translate="label" sortOrder="4" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Soap Body</label>
<frontend_model>Learning\Test\Block\Adminhtml\Form\Field\Config\Create\Configbody</frontend_model>
<backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
</field>
</group>
</section>
</system>
</config>
/app/code/Learning/Test/etc/acl.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<!-- this resource id we can use in system.xml for section -->
<resource id="Learning_Test::config_custom" title="Custom Section" sortOrder="81" />
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
/app/code/Learning/Test/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Learning_Test" setup_version="1.0.0" />
</config>
/app/code/Learning/composer.json
{
"name": "Learning/module-test",
"description": "N/A",
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0"
},
"type": "magento2-module",
"version": "1.0.0",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Learning\\test\\": ""
}
}
}
/app/code/Learning/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Learning_Test',
__DIR__
);
after paste above code execute below command in your CLI:
at last open your control panel try to save as shown below image format
after saving configuration it will show you below image.
In Magento 1 there is no issue and working fine. In Magento 2 it's producing like above special characters.
Please let us know if any information needed.
This is also happening in Outgoing emails in the system, FYI.
The issues already fixed and will be available with release 2.2.0 very soon
I have created a field in system configuration like below
In this field i can dynamically add no.of items In this field if i enter any values in the textbox its rendering perfectly except for special characters.
For example if i enter
<
,>
its rendering as<
and>
However Its saving corretly in database(core_config_data
table) like belowa:4:{s:18:"_1446022331413_413";a:1:{s:6:"header";s:38:"<?xml version="1.0" encoding="utf-8"?>";}s:18:"_1446022332405_405";a:1:{s:6:"header";s:70:"<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">";}s:18:"_1446022348135_135";a:1:{s:6:"header";s:101:"<soap:Body><AddMagentoCustomer xmlns="urn:microsoft-dynamics-schemas/codeunit/AcceptMagentoCustomer">";}s:7:"__empty";s:0:"";}
But could not rendering properly in magento. Its showing as below
while debugging my field values are rendering correctly like below
but when it is loaded its showing unmarked field values like below
Please help me on rendering special characters properly.