Skip to content

Not possible to use multidimensional arrays in widget parameters #19909

Closed
@ilnytskyi

Description

@ilnytskyi

Summary (*)

Magento
2.2.*, 2.2.5, 2.2.6, 2.2.7

Not possible to use multidimensional arrays in widget parameters
When add custom field set as a block parameter type to widget.xml

Examples (*)

Add custom parameter type (in my case it is an options panel)
selection_007

Use parameters names and keys like this

parameters[groups_options][order][option[1]: 0
parameters[groups_options][title][option][1][store][0]: store_label_admin
parameters[groups_options][title][option][1][store][1]: store_label_1
parameters[groups_options][title][option][1][store][2]: store_label_2

See an error
selection_008

in this file the code looks like this
magento/vendor/magento/module-widget/Model/Widget/Instance.php:609

            if ($name == 'conditions') {
                $name = 'conditions_encoded';
                $value = $this->conditionsHelper->encode($value);
            } elseif (is_array($value)) {
                $value = implode(',', $value); 
            }

It is not really possible to reproduce on vanilla instance but we can try to substitute a request parameters for existing widget fields

Proposed solution

// can't we simply serialize an input here instead of implode it ?
// anyway in the database 'widget_instance' all widget values are included in json 
 $value = implode(',', $value); 

selection_009

Metadata

Metadata

Assignees

Labels

Component: WidgetFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed 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 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions