Magento 2 - Hide/Show custom EAV attribute after if conditionIs it possible to save attribute value per store in custom eav based model?Magento 2: How to add a custom attribute to the CMS PageCan virtual types be used as source models for EAV attributes?EAV default attribute value not taking effectCustom EAV model in magento 2Magento 2 add custom product attribute validation from install scriptHide EAV custom fieldGet attribute value of custom eav model in magento 2Magento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento 2 - get EAV value and display it on admin Grid

Reverse ColorFunction or ColorData

Installing Debian 10, upgrade to stable later?

How to deal with employer who keeps me at work after working hours

Where to draw the line between quantum mechanics theory and its interpretation(s)?

How to use awk to extract data from a file based on the content of another file?

What does のそ mean on this picture?

How is trade in services conducted under the WTO in the absence of the Doha conclusion?

Python 3 - simple temperature program version 1.3

Does Thanos's ship land in the middle of the battlefield in "Avengers: Endgame"?

Is there precedent or are there procedures for a US president refusing to concede to an electoral defeat?

Collision domain question

What detail can Hubble see on Mars?

Convert Numbers To Emoji Math

All of my Firefox add-ons been disabled suddenly, how can I re-enable them?

How can I obtain and work with a Platonic dodecahedron?

Debian 9 server no sshd in auth.log

How to say something covers all the view up to the horizon line?

Endgame puzzle: How to avoid stalemate and win?

How is Pauli's exclusion principle still valid in these cases?

Why increasing of the temperature of the objects like wood, paper etc. doesn't fire them?

The selling of the sheep

Can an earth elemental drag a tiny creature underground with Earth Glide?

Is throwing dice a stochastic or a deterministic process?

What do you call a painting painted on a wall?



Magento 2 - Hide/Show custom EAV attribute after if condition


Is it possible to save attribute value per store in custom eav based model?Magento 2: How to add a custom attribute to the CMS PageCan virtual types be used as source models for EAV attributes?EAV default attribute value not taking effectCustom EAV model in magento 2Magento 2 add custom product attribute validation from install scriptHide EAV custom fieldGet attribute value of custom eav model in magento 2Magento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento 2 - get EAV value and display it on admin Grid






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I created a new EAV attribute using this code :



'information',
[
'group' => 'Content',
'type' => 'int',
'default' => null,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => false
]


PS: I added this attribute to the product form



this attribute is by default hidden, but I want to visible it after a condition, is there any method to do that?










share|improve this question






























    0















    I created a new EAV attribute using this code :



    'information',
    [
    'group' => 'Content',
    'type' => 'int',
    'default' => null,
    'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
    'visible' => false
    ]


    PS: I added this attribute to the product form



    this attribute is by default hidden, but I want to visible it after a condition, is there any method to do that?










    share|improve this question


























      0












      0








      0


      1






      I created a new EAV attribute using this code :



      'information',
      [
      'group' => 'Content',
      'type' => 'int',
      'default' => null,
      'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
      'visible' => false
      ]


      PS: I added this attribute to the product form



      this attribute is by default hidden, but I want to visible it after a condition, is there any method to do that?










      share|improve this question
















      I created a new EAV attribute using this code :



      'information',
      [
      'group' => 'Content',
      'type' => 'int',
      'default' => null,
      'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
      'visible' => false
      ]


      PS: I added this attribute to the product form



      this attribute is by default hidden, but I want to visible it after a condition, is there any method to do that?







      magento2 eav eav-attributes






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago







      sayou

















      asked May 2 at 15:28









      sayousayou

      1619




      1619




















          1 Answer
          1






          active

          oldest

          votes


















          1














          You can easily do that using a plugin. Try following way to doing this. Following example will hide product name. For your custom attribute you need to modify plugin code.




          app/code/SR/MagentoCommunity/etc/adminhtml/di.xml




          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCatalogUiDataProviderProductFormModifierGeneral">
          <plugin name="sr_attribute_visibility"
          type="SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifierGeneral" sortOrder="1"/>
          </type>
          </config>



          app/code/SR/MagentoCommunity/Plugin/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php




          <?php
          namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;


          class General

          public function afterModifyMeta(
          MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
          $meta
          )
          // add your condition
          $meta['product-details']['children']['container_name']['children']['name']['arguments']['data']['config']['visible'] = 0;
          // print $meta and check your custom attribute index.
          return $meta;




          [Update]



          Suppose information is text attribute. Now modify following way:



          <?php
          namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;


          class General

          public function afterModifyMeta(
          MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
          $meta
          )
          // add your condition
          if (isset($meta['product-details']['children']['container_information']))
          $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;


          return $meta;




          PS: the attribute visibility should be by default: true (false don't work)






          share|improve this answer

























          • Thanks for your reply sir, That I need to change this ['name'] with ['information'] ? name of my EAV attribute

            – sayou
            May 2 at 17:13












          • I think you need to change container_name too. In your case should container_information.

            – Sohel Rana
            May 2 at 17:14











          • I get this error The "componentType" configuration parameter is required for the "container_information" component

            – sayou
            May 2 at 17:16











          • Try using: $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;

            – Sohel Rana
            May 2 at 17:22











          • Check updated answer

            – Sohel Rana
            May 2 at 17:24











          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
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f273244%2fmagento-2-hide-show-custom-eav-attribute-after-if-condition%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You can easily do that using a plugin. Try following way to doing this. Following example will hide product name. For your custom attribute you need to modify plugin code.




          app/code/SR/MagentoCommunity/etc/adminhtml/di.xml




          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCatalogUiDataProviderProductFormModifierGeneral">
          <plugin name="sr_attribute_visibility"
          type="SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifierGeneral" sortOrder="1"/>
          </type>
          </config>



          app/code/SR/MagentoCommunity/Plugin/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php




          <?php
          namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;


          class General

          public function afterModifyMeta(
          MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
          $meta
          )
          // add your condition
          $meta['product-details']['children']['container_name']['children']['name']['arguments']['data']['config']['visible'] = 0;
          // print $meta and check your custom attribute index.
          return $meta;




          [Update]



          Suppose information is text attribute. Now modify following way:



          <?php
          namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;


          class General

          public function afterModifyMeta(
          MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
          $meta
          )
          // add your condition
          if (isset($meta['product-details']['children']['container_information']))
          $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;


          return $meta;




          PS: the attribute visibility should be by default: true (false don't work)






          share|improve this answer

























          • Thanks for your reply sir, That I need to change this ['name'] with ['information'] ? name of my EAV attribute

            – sayou
            May 2 at 17:13












          • I think you need to change container_name too. In your case should container_information.

            – Sohel Rana
            May 2 at 17:14











          • I get this error The "componentType" configuration parameter is required for the "container_information" component

            – sayou
            May 2 at 17:16











          • Try using: $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;

            – Sohel Rana
            May 2 at 17:22











          • Check updated answer

            – Sohel Rana
            May 2 at 17:24















          1














          You can easily do that using a plugin. Try following way to doing this. Following example will hide product name. For your custom attribute you need to modify plugin code.




          app/code/SR/MagentoCommunity/etc/adminhtml/di.xml




          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCatalogUiDataProviderProductFormModifierGeneral">
          <plugin name="sr_attribute_visibility"
          type="SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifierGeneral" sortOrder="1"/>
          </type>
          </config>



          app/code/SR/MagentoCommunity/Plugin/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php




          <?php
          namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;


          class General

          public function afterModifyMeta(
          MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
          $meta
          )
          // add your condition
          $meta['product-details']['children']['container_name']['children']['name']['arguments']['data']['config']['visible'] = 0;
          // print $meta and check your custom attribute index.
          return $meta;




          [Update]



          Suppose information is text attribute. Now modify following way:



          <?php
          namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;


          class General

          public function afterModifyMeta(
          MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
          $meta
          )
          // add your condition
          if (isset($meta['product-details']['children']['container_information']))
          $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;


          return $meta;




          PS: the attribute visibility should be by default: true (false don't work)






          share|improve this answer

























          • Thanks for your reply sir, That I need to change this ['name'] with ['information'] ? name of my EAV attribute

            – sayou
            May 2 at 17:13












          • I think you need to change container_name too. In your case should container_information.

            – Sohel Rana
            May 2 at 17:14











          • I get this error The "componentType" configuration parameter is required for the "container_information" component

            – sayou
            May 2 at 17:16











          • Try using: $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;

            – Sohel Rana
            May 2 at 17:22











          • Check updated answer

            – Sohel Rana
            May 2 at 17:24













          1












          1








          1







          You can easily do that using a plugin. Try following way to doing this. Following example will hide product name. For your custom attribute you need to modify plugin code.




          app/code/SR/MagentoCommunity/etc/adminhtml/di.xml




          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCatalogUiDataProviderProductFormModifierGeneral">
          <plugin name="sr_attribute_visibility"
          type="SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifierGeneral" sortOrder="1"/>
          </type>
          </config>



          app/code/SR/MagentoCommunity/Plugin/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php




          <?php
          namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;


          class General

          public function afterModifyMeta(
          MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
          $meta
          )
          // add your condition
          $meta['product-details']['children']['container_name']['children']['name']['arguments']['data']['config']['visible'] = 0;
          // print $meta and check your custom attribute index.
          return $meta;




          [Update]



          Suppose information is text attribute. Now modify following way:



          <?php
          namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;


          class General

          public function afterModifyMeta(
          MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
          $meta
          )
          // add your condition
          if (isset($meta['product-details']['children']['container_information']))
          $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;


          return $meta;




          PS: the attribute visibility should be by default: true (false don't work)






          share|improve this answer















          You can easily do that using a plugin. Try following way to doing this. Following example will hide product name. For your custom attribute you need to modify plugin code.




          app/code/SR/MagentoCommunity/etc/adminhtml/di.xml




          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCatalogUiDataProviderProductFormModifierGeneral">
          <plugin name="sr_attribute_visibility"
          type="SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifierGeneral" sortOrder="1"/>
          </type>
          </config>



          app/code/SR/MagentoCommunity/Plugin/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php




          <?php
          namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;


          class General

          public function afterModifyMeta(
          MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
          $meta
          )
          // add your condition
          $meta['product-details']['children']['container_name']['children']['name']['arguments']['data']['config']['visible'] = 0;
          // print $meta and check your custom attribute index.
          return $meta;




          [Update]



          Suppose information is text attribute. Now modify following way:



          <?php
          namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;


          class General

          public function afterModifyMeta(
          MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
          $meta
          )
          // add your condition
          if (isset($meta['product-details']['children']['container_information']))
          $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;


          return $meta;




          PS: the attribute visibility should be by default: true (false don't work)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 days ago









          sayou

          1619




          1619










          answered May 2 at 17:01









          Sohel RanaSohel Rana

          23.9k34461




          23.9k34461












          • Thanks for your reply sir, That I need to change this ['name'] with ['information'] ? name of my EAV attribute

            – sayou
            May 2 at 17:13












          • I think you need to change container_name too. In your case should container_information.

            – Sohel Rana
            May 2 at 17:14











          • I get this error The "componentType" configuration parameter is required for the "container_information" component

            – sayou
            May 2 at 17:16











          • Try using: $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;

            – Sohel Rana
            May 2 at 17:22











          • Check updated answer

            – Sohel Rana
            May 2 at 17:24

















          • Thanks for your reply sir, That I need to change this ['name'] with ['information'] ? name of my EAV attribute

            – sayou
            May 2 at 17:13












          • I think you need to change container_name too. In your case should container_information.

            – Sohel Rana
            May 2 at 17:14











          • I get this error The "componentType" configuration parameter is required for the "container_information" component

            – sayou
            May 2 at 17:16











          • Try using: $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;

            – Sohel Rana
            May 2 at 17:22











          • Check updated answer

            – Sohel Rana
            May 2 at 17:24
















          Thanks for your reply sir, That I need to change this ['name'] with ['information'] ? name of my EAV attribute

          – sayou
          May 2 at 17:13






          Thanks for your reply sir, That I need to change this ['name'] with ['information'] ? name of my EAV attribute

          – sayou
          May 2 at 17:13














          I think you need to change container_name too. In your case should container_information.

          – Sohel Rana
          May 2 at 17:14





          I think you need to change container_name too. In your case should container_information.

          – Sohel Rana
          May 2 at 17:14













          I get this error The "componentType" configuration parameter is required for the "container_information" component

          – sayou
          May 2 at 17:16





          I get this error The "componentType" configuration parameter is required for the "container_information" component

          – sayou
          May 2 at 17:16













          Try using: $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;

          – Sohel Rana
          May 2 at 17:22





          Try using: $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;

          – Sohel Rana
          May 2 at 17:22













          Check updated answer

          – Sohel Rana
          May 2 at 17:24





          Check updated answer

          – Sohel Rana
          May 2 at 17:24

















          draft saved

          draft discarded
















































          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%2f273244%2fmagento-2-hide-show-custom-eav-attribute-after-if-condition%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

          Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

          Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

          Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림