cancel
Showing results for 
Search instead for 
Did you mean: 

Disable "Qty" in Product Form (adminhtml)

Disable "Qty" in Product Form (adminhtml)

Hi, 

 

I'm trying to add some extra field and the most important to me is disable Qty field in the product form in Admin Magento 2.

 

I have created a product_form.xml in My\Module\view\adminhtml\ui_component.

 

This code add the mobile fieldset correctly, however it is not disable the field qty.

 

Anyone could help me with this?

 

<?xml version="1.0" encoding="UTF-8"?>

<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="mobile">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Mobile</item>
<item name="provider" xsi:type="string">product</item>
<item name="dataScope" xsi:type="string">data.product</item>
<item name="sortOrder" xsi:type="number">150</item>
<item name="collapsible" xsi:type="boolean">true</item>
<item name="opened" xsi:type="boolean">false</item>
<item name="ns" xsi:type="string">product_form</item>
</item>
</argument>

<field name="attribute_name">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="sortOrder" xsi:type="number">10</item>
<item name="dataType" xsi:type="string">int</item>
<item name="formElement" xsi:type="string">input</item>
<item name="label" xsi:type="string" translate="true">Attribute Name</item>
<item name="dataScope" xsi:type="string">attribute_name</item>
</item>
</argument>
</field>

</fieldset>
<fieldset name="stock_data">
<field name="qty">
<argument name="data" xsi:type="array">
<item name="disabled" xsi:type="boolean">true</item>
</argument>
</field>
</fieldset>
</form>