Skip to content

Commit 4db56b5

Browse files
author
Bohdan Korablov
committed
MAGETWO-49190: Attribute type Yes\No (checkbox) works incorrectly, always sends value 0
1 parent 0e31e0d commit 4db56b5

File tree

1 file changed

+21
-0
lines changed
  • app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier

1 file changed

+21
-0
lines changed

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,27 @@ protected function setupMetaProperties(ProductAttributeInterface $attribute)
462462
}
463463

464464
$meta = $this->addWysiwyg($attribute, $meta);
465+
$meta = $this->customizeCheckbox($attribute, $meta);
466+
467+
return $meta;
468+
}
469+
470+
/**
471+
* Customize checkboxes
472+
*
473+
* @param ProductAttributeInterface $attribute
474+
* @param array $meta
475+
* @return array
476+
*/
477+
private function customizeCheckbox(ProductAttributeInterface $attribute, array $meta)
478+
{
479+
if ($attribute->getFrontendInput() === 'boolean') {
480+
$meta['arguments']['data']['config']['prefer'] = 'toggle';
481+
$meta['arguments']['data']['config']['valueMap'] = [
482+
'true' => '1',
483+
'false' => '0',
484+
];
485+
}
465486

466487
return $meta;
467488
}

0 commit comments

Comments
 (0)