Skip to content

Commit 50bf8bb

Browse files
committed
Merge branch 'MC-3410' into MC-1413
2 parents b10e7d2 + 715f498 commit 50bf8bb

File tree

3 files changed

+13
-4
lines changed
  • app/code/Magento/PageBuilder
  • dev/tests/integration/testsuite/Magento/PageBuilder/Controller/Adminhtml/Form/Element/ProductConditions

3 files changed

+13
-4
lines changed

app/code/Magento/PageBuilder/Block/Adminhtml/Form/Element/ProductConditions.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ private function getConfig(): array
5252
{
5353
$formNamespace = $this->getData('formNamespace');
5454
$attribute = $this->getData('attribute');
55+
$jsObjectName = $formNamespace . '_' . $attribute;
5556

5657
return [
5758
'formNamespace' => $formNamespace,
@@ -62,12 +63,13 @@ private function getConfig(): array
6263
'prefix' => $attribute,
6364
]
6465
),
65-
'jsObjectName' => $formNamespace . '_' . $attribute,
66+
'jsObjectName' => $jsObjectName,
6667
'childComponentUrl' => $this->getUrl(
6768
'pagebuilder/form/element_productconditions_child',
6869
[
6970
'form_namespace' => $formNamespace,
7071
'prefix' => $attribute,
72+
'js_object_name' => $jsObjectName,
7173
]
7274
),
7375
'attribute' => $attribute,

app/code/Magento/PageBuilder/Controller/Adminhtml/Form/Element/ProductConditions/Child.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function execute()
3939
{
4040
$id = $this->getRequest()->getParam('id');
4141
$formName = $this->getRequest()->getParam('form_namespace');
42+
$jsObjectName = $this->getRequest()->getParam('js_object_name');
4243

4344
$typeData = explode('|', str_replace('-', '/', $this->getRequest()->getParam('type')));
4445
$className = $typeData[0];
@@ -55,7 +56,7 @@ public function execute()
5556

5657
$result = '';
5758
if ($model instanceof AbstractCondition) {
58-
$model->setJsFormObject($formName);
59+
$model->setJsFormObject($jsObjectName);
5960
$model->setFormName($formName);
6061
$result = $model->asHtmlRecursive();
6162
}

dev/tests/integration/testsuite/Magento/PageBuilder/Controller/Adminhtml/Form/Element/ProductConditions/ChildTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,20 @@ public function testFormLoadsEmptyFormUsingParams()
1414
{
1515
$this->getRequest()
1616
->setParams([
17+
'js_object_name' => 'myobject',
1718
'form_namespace' => 'test_namespace',
1819
])
1920
->setPostValue([
20-
'type' => 'Magento\CatalogWidget\Model\Rule\Condition\Product|custom_design_from',
21+
'type' => 'Magento\CatalogWidget\Model\Rule\Condition\Product|category_ids',
2122
'id' => '1--3',
2223
]);
2324

2425
$this->dispatch('backend/pagebuilder/form/element_productconditions_child');
2526
$responseBody = $this->getResponse()->getBody();
2627
// Assert form is associated correctly
2728
$this->assertContains('data-form-part="test_namespace"', $responseBody);
29+
// Assert the form object is propagated
30+
$this->assertContains('form/myobject', $responseBody);
2831
// Assert id is used
2932
$this->assertContains('name="parameters[conditions][1--3][type]"', $responseBody);
3033
// Assert type is used
@@ -35,17 +38,20 @@ public function testFormLoadsCustomPrefix()
3538
{
3639
$this->getRequest()
3740
->setParams([
41+
'js_object_name' => 'myobject',
3842
'form_namespace' => 'test_namespace',
3943
'prefix' => 'myprefix',
4044
])
4145
->setPostValue([
42-
'type' => 'Magento\CatalogWidget\Model\Rule\Condition\Product|custom_design_from',
46+
'type' => 'Magento\CatalogWidget\Model\Rule\Condition\Product|category_ids',
4347
'id' => '1--3',
4448
]);
4549

4650
$this->dispatch('backend/pagebuilder/form/element_productconditions_child');
4751
$responseBody = $this->getResponse()->getBody();
4852

53+
// Assert the form object is propagated
54+
$this->assertContains('form/myobject', $responseBody);
4955
// Assert id is used
5056
$this->assertContains('name="parameters[myprefix][1--3][type]"', $responseBody);
5157
}

0 commit comments

Comments
 (0)