Enable/Disable field in admin product edit form with radio button. (Magento 2)Admin form field buttonMagento 2 add custom product attribute validation from install scriptMagento 2.1 Create a filter in the product grid by new attributeMagento 2 Add new field to Magento_User admin formI have created one field using product form field for my price i want save my field value at product creation time from backend magento2Add button in Magento2 Edit FormMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?In magento 2 admin custom field value stored in db but when edit a product edit page custom field came empty, how to solve thisMagento Fatal Error on Running InstallationHow to change “input file” storage location in customer account edit form
Are the Gray and Death Slaad's Bite and Claw attacks magical?
Merging two data frames into a new one with unique items marked with 1 or 0
Polynomial and roots problems
Why will we fail creating a self sustaining off world colony?
What is the meaning of "it" in "as luck would have it"?
How to idiomatically express the idea "if you can cheat without being caught, do it"
Disk usage confusion: 10G missing on Linux home partition on SSD
How can I change my buffer system for protein purification?
What is the point of using the kunai?
Existence of infinite set of positive integers s.t sum of reciprocals is rational and set of primes dividing an element is infinite
How can I know (without going to the station) if RATP is offering the Anti Pollution tickets?
Russian equivalents of 能骗就骗 (if you can cheat, then cheat)
Is it normal for professors to hold their graduate students "hostage?"
How to extract coefficients of a generating function like this one, using a computer?
How soon after takeoff can you recline your airplane seat?
Making arrow with a gradual colour
Why would Dementors torture a Death Eater if they are loyal to Voldemort?
Which high-degree derivatives play an essential role?
Why are symbols not written in words?
Is it OK to throw pebbles and stones in streams, waterfalls, ponds, etc.?
"Best practices" for formulating MIPs
Is it advisable to inform the CEO about his brother accessing his office?
My mom helped me cosign a car and now she wants to take it
Turing Machines: What is the difference between recognizing, deciding, total, accepting, rejecting?
Enable/Disable field in admin product edit form with radio button. (Magento 2)
Admin form field buttonMagento 2 add custom product attribute validation from install scriptMagento 2.1 Create a filter in the product grid by new attributeMagento 2 Add new field to Magento_User admin formI have created one field using product form field for my price i want save my field value at product creation time from backend magento2Add button in Magento2 Edit FormMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?In magento 2 admin custom field value stored in db but when edit a product edit page custom field came empty, how to solve thisMagento Fatal Error on Running InstallationHow to change “input file” storage location in customer account edit form
I try to enable "Field to be enable" when radio button "Enable field" is checked. You can see screenshot
field to be enable
UpgradeData.php
$eavSetup->addAttribute(
MagentoCatalogModelProduct::ENTITY,
'stop_production',
[
'group' => 'Product Details',
'type' => 'int',
'label' => 'Enabled field',
'input' => 'boolean',
'source' => 'MagentoEavModelEntityAttributeSourceBoolean',
'default' => '0',
'required' => false,
'sort_order' => 50,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
'visible' => true
]
);
$eavSetup->addAttribute(
MagentoCatalogModelProduct::ENTITY,
'item_replace', [
'type' => 'text',
'label' => 'Field to be enable',
'input' => 'text',
'sort_order' => 55,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
'required' => false,
'group' => 'Product Details',
'backend' => 'WoStopProductionModelAttributeBackendItemReplace'
]);
Class ItemReplace.php ( use for disabled field but not working )
{
protected $arrayManager;
public function __construct(
ArrayManager $arrayManager
)
$this->arrayManager = $arrayManager;
public function modifyMeta(array $meta)
$meta = $this->customizeItemReplace($meta);
return $meta;
public function modifyData(array $data)
return $data;
protected function customizeItemReplace(array $meta)
$weightPath = $this->arrayManager->findPath('item_replace', $meta, null, 'children');
if ($weightPath)
$meta = $this->arrayManager->merge(
$weightPath . static::META_CONFIG_PATH,
$meta,
[
'dataScope' => 'item_replace',
'validation' => [
'required-entry' => true
],
'additionalClasses' => 'admin__field-small',
'imports' => [
'disabled' => '!$$.provider:' . self::DATA_SCOPE_PRODUCT
. '.stop_production:value'
]
]
);
return $meta;
di.xml
<virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="item_replace" xsi:type="array">
<item name="class" xsi:type="string">WoStopProductionUiDataProviderProductFormModifierItemReplace</item>
<item name="sortOrder" xsi:type="number">10</item>
</item>
</argument>
</arguments>
</virtualType>
First problem: modifier not work for disable field.
Second problem: how can render field enable and required when radio button is enable ?
Many thanks for your help
magento2 adminform product-edit-page
New contributor
add a comment |
I try to enable "Field to be enable" when radio button "Enable field" is checked. You can see screenshot
field to be enable
UpgradeData.php
$eavSetup->addAttribute(
MagentoCatalogModelProduct::ENTITY,
'stop_production',
[
'group' => 'Product Details',
'type' => 'int',
'label' => 'Enabled field',
'input' => 'boolean',
'source' => 'MagentoEavModelEntityAttributeSourceBoolean',
'default' => '0',
'required' => false,
'sort_order' => 50,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
'visible' => true
]
);
$eavSetup->addAttribute(
MagentoCatalogModelProduct::ENTITY,
'item_replace', [
'type' => 'text',
'label' => 'Field to be enable',
'input' => 'text',
'sort_order' => 55,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
'required' => false,
'group' => 'Product Details',
'backend' => 'WoStopProductionModelAttributeBackendItemReplace'
]);
Class ItemReplace.php ( use for disabled field but not working )
{
protected $arrayManager;
public function __construct(
ArrayManager $arrayManager
)
$this->arrayManager = $arrayManager;
public function modifyMeta(array $meta)
$meta = $this->customizeItemReplace($meta);
return $meta;
public function modifyData(array $data)
return $data;
protected function customizeItemReplace(array $meta)
$weightPath = $this->arrayManager->findPath('item_replace', $meta, null, 'children');
if ($weightPath)
$meta = $this->arrayManager->merge(
$weightPath . static::META_CONFIG_PATH,
$meta,
[
'dataScope' => 'item_replace',
'validation' => [
'required-entry' => true
],
'additionalClasses' => 'admin__field-small',
'imports' => [
'disabled' => '!$$.provider:' . self::DATA_SCOPE_PRODUCT
. '.stop_production:value'
]
]
);
return $meta;
di.xml
<virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="item_replace" xsi:type="array">
<item name="class" xsi:type="string">WoStopProductionUiDataProviderProductFormModifierItemReplace</item>
<item name="sortOrder" xsi:type="number">10</item>
</item>
</argument>
</arguments>
</virtualType>
First problem: modifier not work for disable field.
Second problem: how can render field enable and required when radio button is enable ?
Many thanks for your help
magento2 adminform product-edit-page
New contributor
add a comment |
I try to enable "Field to be enable" when radio button "Enable field" is checked. You can see screenshot
field to be enable
UpgradeData.php
$eavSetup->addAttribute(
MagentoCatalogModelProduct::ENTITY,
'stop_production',
[
'group' => 'Product Details',
'type' => 'int',
'label' => 'Enabled field',
'input' => 'boolean',
'source' => 'MagentoEavModelEntityAttributeSourceBoolean',
'default' => '0',
'required' => false,
'sort_order' => 50,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
'visible' => true
]
);
$eavSetup->addAttribute(
MagentoCatalogModelProduct::ENTITY,
'item_replace', [
'type' => 'text',
'label' => 'Field to be enable',
'input' => 'text',
'sort_order' => 55,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
'required' => false,
'group' => 'Product Details',
'backend' => 'WoStopProductionModelAttributeBackendItemReplace'
]);
Class ItemReplace.php ( use for disabled field but not working )
{
protected $arrayManager;
public function __construct(
ArrayManager $arrayManager
)
$this->arrayManager = $arrayManager;
public function modifyMeta(array $meta)
$meta = $this->customizeItemReplace($meta);
return $meta;
public function modifyData(array $data)
return $data;
protected function customizeItemReplace(array $meta)
$weightPath = $this->arrayManager->findPath('item_replace', $meta, null, 'children');
if ($weightPath)
$meta = $this->arrayManager->merge(
$weightPath . static::META_CONFIG_PATH,
$meta,
[
'dataScope' => 'item_replace',
'validation' => [
'required-entry' => true
],
'additionalClasses' => 'admin__field-small',
'imports' => [
'disabled' => '!$$.provider:' . self::DATA_SCOPE_PRODUCT
. '.stop_production:value'
]
]
);
return $meta;
di.xml
<virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="item_replace" xsi:type="array">
<item name="class" xsi:type="string">WoStopProductionUiDataProviderProductFormModifierItemReplace</item>
<item name="sortOrder" xsi:type="number">10</item>
</item>
</argument>
</arguments>
</virtualType>
First problem: modifier not work for disable field.
Second problem: how can render field enable and required when radio button is enable ?
Many thanks for your help
magento2 adminform product-edit-page
New contributor
I try to enable "Field to be enable" when radio button "Enable field" is checked. You can see screenshot
field to be enable
UpgradeData.php
$eavSetup->addAttribute(
MagentoCatalogModelProduct::ENTITY,
'stop_production',
[
'group' => 'Product Details',
'type' => 'int',
'label' => 'Enabled field',
'input' => 'boolean',
'source' => 'MagentoEavModelEntityAttributeSourceBoolean',
'default' => '0',
'required' => false,
'sort_order' => 50,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
'visible' => true
]
);
$eavSetup->addAttribute(
MagentoCatalogModelProduct::ENTITY,
'item_replace', [
'type' => 'text',
'label' => 'Field to be enable',
'input' => 'text',
'sort_order' => 55,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
'required' => false,
'group' => 'Product Details',
'backend' => 'WoStopProductionModelAttributeBackendItemReplace'
]);
Class ItemReplace.php ( use for disabled field but not working )
{
protected $arrayManager;
public function __construct(
ArrayManager $arrayManager
)
$this->arrayManager = $arrayManager;
public function modifyMeta(array $meta)
$meta = $this->customizeItemReplace($meta);
return $meta;
public function modifyData(array $data)
return $data;
protected function customizeItemReplace(array $meta)
$weightPath = $this->arrayManager->findPath('item_replace', $meta, null, 'children');
if ($weightPath)
$meta = $this->arrayManager->merge(
$weightPath . static::META_CONFIG_PATH,
$meta,
[
'dataScope' => 'item_replace',
'validation' => [
'required-entry' => true
],
'additionalClasses' => 'admin__field-small',
'imports' => [
'disabled' => '!$$.provider:' . self::DATA_SCOPE_PRODUCT
. '.stop_production:value'
]
]
);
return $meta;
di.xml
<virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="item_replace" xsi:type="array">
<item name="class" xsi:type="string">WoStopProductionUiDataProviderProductFormModifierItemReplace</item>
<item name="sortOrder" xsi:type="number">10</item>
</item>
</argument>
</arguments>
</virtualType>
First problem: modifier not work for disable field.
Second problem: how can render field enable and required when radio button is enable ?
Many thanks for your help
magento2 adminform product-edit-page
magento2 adminform product-edit-page
New contributor
New contributor
edited Jun 24 at 11:43
Abdul Pathan
1617 bronze badges
1617 bronze badges
New contributor
asked Jun 24 at 11:34
gatch14gatch14
1
1
New contributor
New contributor
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
gatch14 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f279404%2fenable-disable-field-in-admin-product-edit-form-with-radio-button-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
gatch14 is a new contributor. Be nice, and check out our Code of Conduct.
gatch14 is a new contributor. Be nice, and check out our Code of Conduct.
gatch14 is a new contributor. Be nice, and check out our Code of Conduct.
gatch14 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f279404%2fenable-disable-field-in-admin-product-edit-form-with-radio-button-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown