I have a field which i don't want to show. But this field needs to be required.

this field should be populated when we click on specific button via ajax.

so we have something like that:

        <field name="myfield" formElement="textarea" sortOrder="120">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">Source</item>
                    <item name="visible" xsi:type="boolean">false</item>
                    <item name="disabled" xsi:type="boolean">true</item>
                <label translate="true">My field</label>
                    <rule name="required-entry" xsi:type="boolean">true</rule>
    <htmlContent name="html_content">
        <block name="html_content_block" class="Namespace\Module\Block\Adminhtml\Myblock">
                <argument name="template" xsi:type="string">Namespace_Module::template.phtml</argument>

html element is used to add button we need and javascript which contains ajax call.

This part does work as intended, however user can ignore this part and click on save button which leaves that field empty.

any idea on how to solve this ?

1 Answer 1


Try this way.

<field name="myfield" formElement="hidden">

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.