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













0















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










share|improve this question









New contributor



gatch14 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    0















    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










    share|improve this question









    New contributor



    gatch14 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      0












      0








      0








      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










      share|improve this question









      New contributor



      gatch14 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      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






      share|improve this question









      New contributor



      gatch14 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share|improve this question









      New contributor



      gatch14 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share|improve this question




      share|improve this question








      edited Jun 24 at 11:43









      Abdul Pathan

      1617 bronze badges




      1617 bronze badges






      New contributor



      gatch14 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      asked Jun 24 at 11:34









      gatch14gatch14

      1




      1




      New contributor



      gatch14 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      New contributor




      gatch14 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          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.









          draft saved

          draft discarded


















          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.









          draft saved

          draft discarded


















          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

          Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?