Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Widget] Fixing the multidimensional array as value for the widget's parameter #21008

Merged

Conversation

eduard13
Copy link
Contributor

@eduard13 eduard13 commented Feb 6, 2019

Description (*)

This PR gives the possibility to use a multi row field as a parameter for a widget.

<parameter name="conditions" xsi:type="block" visible="true" sort_order="30">
    <label translate="true">Tabs</label>
    <block class="Atwix\Tabs\Block\Adminhtml\Widget\Form\Element" />
</parameter>

After saving the widget, or opening, you'll have 2 exceptions thrown:
Warning: html_entity_decode() expects parameter 1 to be string, array given in /home/dev/sites/mage23/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php on line 170

Warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/dev/sites/mage23/lib/internal/Magento/Framework/Data/Form/Element/AbstractElement.php on line 290

As a result, you should are able to save and open the widget:
xnip2019-02-06_09-59-09

Fixed Issues (if relevant)

  1. Not possible to use multidimensional arrays in widget parameters #19909: Not possible to use multidimensional arrays in widget parameters
  2. ...

Manual testing scenarios (*)

  1. ...
  2. ...

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @eduard13. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@magento-engcom-team magento-engcom-team added Component: Framework/Data Component: Widget Release Line: 2.3 Partner: Atwix Pull Request is created by partner Atwix partners-contribution Pull Request is created by Magento Partner labels Feb 6, 2019
@eduard13 eduard13 requested a review from dmytro-ch February 6, 2019 08:37
@@ -166,7 +166,9 @@ protected function _addField($parameter)

if (is_array($data['value'])) {
foreach ($data['value'] as &$value) {
$value = html_entity_decode($value);
if (!is_array($value)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to check the value on string type: if(is_string($value)) because this check will fail if $value will be an object

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sidolov makes sense. Thank you.

@magento-engcom-team
Copy link
Contributor

Hi @sidolov, thank you for the review.
ENGCOM-4170 has been created to process this Pull Request

@m2-assistant
Copy link

m2-assistant bot commented Apr 8, 2019

Hi @eduard13, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants