I'm building a custom form in the admin using the UI Form Component, and configuring it in [my_module]/adminhtml/ui_component/form.xml. I have the fields working, but would like to add a 'submit' button at the bottom of the form - I can see that there is a button UI Component defined in vendor/magento/module-ui/view/base/ui_component/etc/definition.xml, but when I add it, I get a small, clickable square at the end of the form with no text:

<field name="submit">
   <argument name="data" xsi:type="array">
       <item name="config" xsi:type="array">
           <item name="label" xsi:type="string">Submit</item>
           <item name="visible" xsi:type="boolean">true</item>
           <item name="dataType" xsi:type="string">submit</item>
           <item name="formElement" xsi:type="string">button</item>
           <item name="source" xsi:type="string">form</item>

How do I add a submit button to a form using UI Component?

  • I don't have a solution yet, but just curious, why do you need a submit button INSIDE the form when you can have one in the floating header above the form as the rest of the ui component generated forms? – Marius Dec 14 '16 at 14:46
  • @Marius - I guess I can use that, but it's a break from a pretty classic design standard: usually CTA buttons are to the lower right of a form, not in a banner above the form. Users may be confused. With the button in the header, you have to define the parameters in a separate Block class - what should the on_click parameter value be to submit the form? (Also, why include a button definition if not for some type of CTA?) – dbcn Dec 15 '16 at 15:27
  • 1
    but users might get more confused if the rest of the backend has the buttons above the form and your form has the button below it. Here is now the save button is added to the cms pages form github.com/magento/magento2/blob/develop/app/code/Magento/Cms/… and here is how the class associated to the button looks like github.com/magento/magento2/blob/develop/app/code/Magento/Cms/… – Marius Dec 15 '16 at 15:31
  • Have you solved it? – Dhaduk Mitesh Feb 25 '20 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.