Disabling a UI component field while add new product in Magento 2How can i rewrite TierPrice Block in...

What Does the Heart In Gyms Mean?

Citing contemporaneous (interlaced?) preprints

Why is working on the same position for more than 15 years not a red flag?

Is the withholding of funding notice allowed?

What is this waxed root vegetable?

Rationale to prefer local variables over instance variables?

In iTunes 12 on macOS, how can I reset the skip count of a song?

Don't know what I’m looking for regarding removable HDDs?

Roots of 6th chords on the guitar for different inversions/voicings

Difference between 'stomach' and 'uterus'

Is there a full canon version of Tyrion's jackass/honeycomb joke?

Why is it "take a leak?"

Inverse of the covariance matrix of a multivariate normal distribution

Are paired adjectives bad style?

When was drinking water recognized as crucial in marathon running?

Is it possible to make a clamp function shorter than a ternary in JS?

For a 1-action spell, do I need to take a turn to ready the spell before I can cast it, or can I cast it immediately?

How to substitute values from a list into a function?

What could trigger powerful quakes on icy world?

Achieving MPPT of a solar panel with LM2596

The need of reserving one's ability in job interviews

What is a term for a function that when called repeatedly, has the same effect as calling once?

In Adventurer's League, is it possible to keep the Ring of Winter if you manage to acquire it in the Tomb of Annihilation adventure?

Giving a talk in my old university, how prominently should I tell students my salary?



Disabling a UI component field while add new product in Magento 2


How can i rewrite TierPrice Block in Magento2Error Add Result page breadcrumbMagento 2 Add new field to Magento_User admin formMagento2 add new field in bundle item (in option selection)Add an extension to edit the product name quickly in admin. Magento 2How Magento 2 serialize Configurable Product data, while savingMagento 2 Grid serialization : not getting selected product idMagento 2 sales order grid custom column export csv issueMagento 2 : Error when Add WYSIWYG Editor to Block FormMagento 2.2.5: Add, Update and Delete existing products Custom Options













2















I have a UI component defining field, I want to display this field while edit existing product, and hide this field when add new product.




NamespaceModulenameviewadminhtmlui_componentproduct_form




<fieldset name="vendorproduct">  
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Seller Sell This Product</item>
<item name="collapsible" xsi:type="boolean">true</item>
<item name="sortOrder" xsi:type="number">65</item>
</item>
</argument>
<container name="vendor_data" >
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="sortOrder" xsi:type="number">10</item>
</item>
</argument>
<htmlContent name="html_content">
<argument name="block" xsi:type="object">NamespaceModulenameBlockAdminhtmlCatalogProductEditTabSeller</argument>
</htmlContent>
</container>
</fieldset>


Using <item name="disabled" xsi:type="boolean">true</item> I can disable fields but I want to disable them while adding new product only. how can I achieve this.



Any help is appreciated. Thanks.










share|improve this question





























    2















    I have a UI component defining field, I want to display this field while edit existing product, and hide this field when add new product.




    NamespaceModulenameviewadminhtmlui_componentproduct_form




    <fieldset name="vendorproduct">  
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="label" xsi:type="string" translate="true">Seller Sell This Product</item>
    <item name="collapsible" xsi:type="boolean">true</item>
    <item name="sortOrder" xsi:type="number">65</item>
    </item>
    </argument>
    <container name="vendor_data" >
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="sortOrder" xsi:type="number">10</item>
    </item>
    </argument>
    <htmlContent name="html_content">
    <argument name="block" xsi:type="object">NamespaceModulenameBlockAdminhtmlCatalogProductEditTabSeller</argument>
    </htmlContent>
    </container>
    </fieldset>


    Using <item name="disabled" xsi:type="boolean">true</item> I can disable fields but I want to disable them while adding new product only. how can I achieve this.



    Any help is appreciated. Thanks.










    share|improve this question



























      2












      2








      2


      1






      I have a UI component defining field, I want to display this field while edit existing product, and hide this field when add new product.




      NamespaceModulenameviewadminhtmlui_componentproduct_form




      <fieldset name="vendorproduct">  
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string" translate="true">Seller Sell This Product</item>
      <item name="collapsible" xsi:type="boolean">true</item>
      <item name="sortOrder" xsi:type="number">65</item>
      </item>
      </argument>
      <container name="vendor_data" >
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="sortOrder" xsi:type="number">10</item>
      </item>
      </argument>
      <htmlContent name="html_content">
      <argument name="block" xsi:type="object">NamespaceModulenameBlockAdminhtmlCatalogProductEditTabSeller</argument>
      </htmlContent>
      </container>
      </fieldset>


      Using <item name="disabled" xsi:type="boolean">true</item> I can disable fields but I want to disable them while adding new product only. how can I achieve this.



      Any help is appreciated. Thanks.










      share|improve this question
















      I have a UI component defining field, I want to display this field while edit existing product, and hide this field when add new product.




      NamespaceModulenameviewadminhtmlui_componentproduct_form




      <fieldset name="vendorproduct">  
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string" translate="true">Seller Sell This Product</item>
      <item name="collapsible" xsi:type="boolean">true</item>
      <item name="sortOrder" xsi:type="number">65</item>
      </item>
      </argument>
      <container name="vendor_data" >
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="sortOrder" xsi:type="number">10</item>
      </item>
      </argument>
      <htmlContent name="html_content">
      <argument name="block" xsi:type="object">NamespaceModulenameBlockAdminhtmlCatalogProductEditTabSeller</argument>
      </htmlContent>
      </container>
      </fieldset>


      Using <item name="disabled" xsi:type="boolean">true</item> I can disable fields but I want to disable them while adding new product only. how can I achieve this.



      Any help is appreciated. Thanks.







      magento2 xml uicomponent






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 17 '18 at 5:34







      Chirag Patel

















      asked May 8 '18 at 5:50









      Chirag PatelChirag Patel

      2,200321




      2,200321






















          2 Answers
          2






          active

          oldest

          votes


















          1














           <virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool">
          <arguments>
          <argument name="modifiers" xsi:type="array">
          <item name="name" xsi:type="array">
          <item name="class" xsi:type="string">NamespaceModuleNamUiDataProviderProductFormModifierAttributes</item>
          <item name="sortOrder" xsi:type="number">1000</item>
          </item>

          </argument>
          </arguments>
          </virtualType>


          public function modifyMeta(array $meta)
          {
          // check to disable attributes on product new
          if ($this->lumaData->getGeneralConfig('lockattributes') == 1) {
          // attributes need to be disabled
          $attributes = array();
          } else {

          $attributes = array();
          }
          if ($this->httpRequest->getActionName() == 'new' ) {
          // code to make the attribute disable
          foreach($attributes as $attribute){

          $path = $this->arrayManager->findPath($attribute, $meta, null, 'children');
          if ($path) {
          $meta = $this->arrayManager->set(
          "{$path}/arguments/data/config/disabled",
          $meta,
          true
          );
          }
          }
          }
          return $meta;
          }
          If you use this you will get solution





          share|improve this answer































            0














            According to the official docs Modifier classes should be used when you need to add validations to display only certain fields for certain product types and also when static declaration is not applicable. Which I think is the case you are describing here.



            https://devdocs.magento.com/guides/v2.3/howdoi/customize-modifier-class.html






            share|improve this answer























              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%2f225057%2fdisabling-a-ui-component-field-while-add-new-product-in-magento-2%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














               <virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool">
              <arguments>
              <argument name="modifiers" xsi:type="array">
              <item name="name" xsi:type="array">
              <item name="class" xsi:type="string">NamespaceModuleNamUiDataProviderProductFormModifierAttributes</item>
              <item name="sortOrder" xsi:type="number">1000</item>
              </item>

              </argument>
              </arguments>
              </virtualType>


              public function modifyMeta(array $meta)
              {
              // check to disable attributes on product new
              if ($this->lumaData->getGeneralConfig('lockattributes') == 1) {
              // attributes need to be disabled
              $attributes = array();
              } else {

              $attributes = array();
              }
              if ($this->httpRequest->getActionName() == 'new' ) {
              // code to make the attribute disable
              foreach($attributes as $attribute){

              $path = $this->arrayManager->findPath($attribute, $meta, null, 'children');
              if ($path) {
              $meta = $this->arrayManager->set(
              "{$path}/arguments/data/config/disabled",
              $meta,
              true
              );
              }
              }
              }
              return $meta;
              }
              If you use this you will get solution





              share|improve this answer




























                1














                 <virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool">
                <arguments>
                <argument name="modifiers" xsi:type="array">
                <item name="name" xsi:type="array">
                <item name="class" xsi:type="string">NamespaceModuleNamUiDataProviderProductFormModifierAttributes</item>
                <item name="sortOrder" xsi:type="number">1000</item>
                </item>

                </argument>
                </arguments>
                </virtualType>


                public function modifyMeta(array $meta)
                {
                // check to disable attributes on product new
                if ($this->lumaData->getGeneralConfig('lockattributes') == 1) {
                // attributes need to be disabled
                $attributes = array();
                } else {

                $attributes = array();
                }
                if ($this->httpRequest->getActionName() == 'new' ) {
                // code to make the attribute disable
                foreach($attributes as $attribute){

                $path = $this->arrayManager->findPath($attribute, $meta, null, 'children');
                if ($path) {
                $meta = $this->arrayManager->set(
                "{$path}/arguments/data/config/disabled",
                $meta,
                true
                );
                }
                }
                }
                return $meta;
                }
                If you use this you will get solution





                share|improve this answer


























                  1












                  1








                  1







                   <virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool">
                  <arguments>
                  <argument name="modifiers" xsi:type="array">
                  <item name="name" xsi:type="array">
                  <item name="class" xsi:type="string">NamespaceModuleNamUiDataProviderProductFormModifierAttributes</item>
                  <item name="sortOrder" xsi:type="number">1000</item>
                  </item>

                  </argument>
                  </arguments>
                  </virtualType>


                  public function modifyMeta(array $meta)
                  {
                  // check to disable attributes on product new
                  if ($this->lumaData->getGeneralConfig('lockattributes') == 1) {
                  // attributes need to be disabled
                  $attributes = array();
                  } else {

                  $attributes = array();
                  }
                  if ($this->httpRequest->getActionName() == 'new' ) {
                  // code to make the attribute disable
                  foreach($attributes as $attribute){

                  $path = $this->arrayManager->findPath($attribute, $meta, null, 'children');
                  if ($path) {
                  $meta = $this->arrayManager->set(
                  "{$path}/arguments/data/config/disabled",
                  $meta,
                  true
                  );
                  }
                  }
                  }
                  return $meta;
                  }
                  If you use this you will get solution





                  share|improve this answer













                   <virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool">
                  <arguments>
                  <argument name="modifiers" xsi:type="array">
                  <item name="name" xsi:type="array">
                  <item name="class" xsi:type="string">NamespaceModuleNamUiDataProviderProductFormModifierAttributes</item>
                  <item name="sortOrder" xsi:type="number">1000</item>
                  </item>

                  </argument>
                  </arguments>
                  </virtualType>


                  public function modifyMeta(array $meta)
                  {
                  // check to disable attributes on product new
                  if ($this->lumaData->getGeneralConfig('lockattributes') == 1) {
                  // attributes need to be disabled
                  $attributes = array();
                  } else {

                  $attributes = array();
                  }
                  if ($this->httpRequest->getActionName() == 'new' ) {
                  // code to make the attribute disable
                  foreach($attributes as $attribute){

                  $path = $this->arrayManager->findPath($attribute, $meta, null, 'children');
                  if ($path) {
                  $meta = $this->arrayManager->set(
                  "{$path}/arguments/data/config/disabled",
                  $meta,
                  true
                  );
                  }
                  }
                  }
                  return $meta;
                  }
                  If you use this you will get solution






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered May 9 '18 at 10:49









                  Sairam SigirisettySairam Sigirisetty

                  2616




                  2616

























                      0














                      According to the official docs Modifier classes should be used when you need to add validations to display only certain fields for certain product types and also when static declaration is not applicable. Which I think is the case you are describing here.



                      https://devdocs.magento.com/guides/v2.3/howdoi/customize-modifier-class.html






                      share|improve this answer




























                        0














                        According to the official docs Modifier classes should be used when you need to add validations to display only certain fields for certain product types and also when static declaration is not applicable. Which I think is the case you are describing here.



                        https://devdocs.magento.com/guides/v2.3/howdoi/customize-modifier-class.html






                        share|improve this answer


























                          0












                          0








                          0







                          According to the official docs Modifier classes should be used when you need to add validations to display only certain fields for certain product types and also when static declaration is not applicable. Which I think is the case you are describing here.



                          https://devdocs.magento.com/guides/v2.3/howdoi/customize-modifier-class.html






                          share|improve this answer













                          According to the official docs Modifier classes should be used when you need to add validations to display only certain fields for certain product types and also when static declaration is not applicable. Which I think is the case you are describing here.



                          https://devdocs.magento.com/guides/v2.3/howdoi/customize-modifier-class.html







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 10 mins ago









                          diazwatsondiazwatson

                          1,53011425




                          1,53011425






























                              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%2f225057%2fdisabling-a-ui-component-field-while-add-new-product-in-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

                              “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

                              How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

                              變成蝙蝠會怎樣? 參考資料 外部連結 导航菜单Thomas Nagel, "What is it like to be a...