1

In magento 2 admin, I want to expandable textarea height using xml. How to do that?

I tried this code. But, it's not working.

<field name="comment">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">text</item>
                    <item name="label" xsi:type="string" translate="true">Comment</item>
                    <item name="formElement" xsi:type="string">textarea</item>
                    <item name="source" xsi:type="string">comment</item>
                    <item name="dataScope" xsi:type="string">comment</item>
                    <item name="cols" xsi:type="number">200</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">true</item>
                    </item>
                </item>
            </argument>
        </field>

Actual Result :

enter image description here

Expected Result :

enter image description here

13
  • what is your expected output here?
    – fmsthird
    May 2, 2019 at 8:31
  • As like screenshot. May 2, 2019 at 8:33
  • ahh.. I think you can define row instead <item name="rows" xsi:type="number">200</item>
    – fmsthird
    May 2, 2019 at 8:34
  • I mean together with the column you have to define the rows as well
    – fmsthird
    May 2, 2019 at 8:35
  • Nope. Still, it's not working. May 2, 2019 at 8:36

1 Answer 1

6

To increase the height of text-area use <item name="rows" xsi:type="number">60</item> insted of <item name="cols" xsi:type="number">200</item>

But the above code is not working as expected and not increase the height of text-area because of Magento CSS issue. to check inspect element and find class .admin__control-textarea you can see css like below.

.admin__control-textarea {
   height: 8.48rem;
   line-height: 1.18;
   padding-top: .8rem;
   resize: vertical;
}

In the above CSS you can see CSS height: 8.48rem; just remove this CSS and see your code is working fine so reason for this CSS your code is not working.

To resolve the above issue try with below way :

Add item to your field <item name="additionalClasses" xsi:type="string">md_product_label_uploader</item> for add custom class to your field and apply custom CSS to this field and it will be working fine.

Note : This is default Magento bug I submitted an issue on GitHub.

I hope it helps!

4
  • 1
    I tried his code in my custom ui form and it works...
    – fmsthird
    May 7, 2019 at 14:32
  • no I mean his code which he says is not working is working for me. so it is not a default magento bug
    – fmsthird
    May 7, 2019 at 21:18
  • @magefms check here it is default Magento bug github.com/magento/magento2/issues/22771 I have reported this bug on GitHub May 8, 2019 at 4:30
  • The height issue appears to have been fixed in Magento, but does anyone have a clue how to pass attributes like rows in custom widget parameters?
    – ACJ
    Feb 17, 2020 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.