Hot answers tagged

46 votes
Accepted

Magento 2 - How to add the DateTime UI Component

To add the dateTime picker you should use the next directive inside the xml file: <field name="start_date"> <argument name="data" xsi:type="array"> ...
Siarhey Uchukhlebau's user avatar
37 votes

UI form validation in Magento 2

Read More: https://mageprince.com/blog/how-to-validate-forms-in-magento-2/ You can use validate-digits for validating number <item name="validation" xsi:type="array"> <item name="...
Prince Patel's user avatar
  • 22.5k
28 votes
Accepted

Magento 2.1 How do I create form component field custom depends on another field value?

Try this (Note: Don't forget to replace the line "Namespace" and the line "ModuleName" with your values): <field name="field1"> <argument name="data" xsi:type="array"> <...
Siarhey Uchukhlebau's user avatar
17 votes

uiComponent Form Save Button Not working

Yo, whats up guys. I just had to wrestle with this in 2.1.9 and think I may have a legit answer. All of these answers are close, but none seem to be completely correct so far. I'll explain how I ...
KazaJhodo's user avatar
  • 193
14 votes
Accepted

Magento 2: How to add color picker in ui form

I recently needed to add a color picker to a category form. Here is what wound up working: Vendor/Module/view/adminhtml/ui_component/category_form.xml <?xml version="1.0"?> <form xmlns:...
Pmclain's user avatar
  • 2,548
14 votes
Accepted

Magento 2: How to submit custom html content from ui_form to controller?

In your block create protected $_template = 'Company_Module::labelposition.phtml'; now, make labelposition.phtml and add your html field with attribute data-form-part="formname". Here the formname ...
SyncTechnolab's user avatar
13 votes
Accepted

Magento 2.2.6 How to add TAB structure in admin UI component form

I found my problem, i used argument item <item name="template" xsi:type="string">templates/form/collapsible</item> it is used to display for collapsible structure. After remove this line ...
Chirag Patel's user avatar
  • 6,066
12 votes

Magento 2.1 How do I create form component field custom depends on another field value?

This is an old question with multiple answers that work, however I have discovered a solution using what Magento provides (as of 2.1.0) without the need for extending components. As multiple questions ...
rain2o's user avatar
  • 465
11 votes
Accepted

How can I add a custom field to an admin form in Magento 2?

You can check the magento sample module they have provided <field name="color"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> ...
Priyank's user avatar
  • 7,602
11 votes

How to set default value for text and select field in admin new UI form in magento 2

You need to add below code: <item name="default" xsi:type="string">1</item> For reference you can check category_form as below <field name="is_active"> <...
Prashant Valanda's user avatar
11 votes
Accepted

Magento 2 How to set value to UI component hidden field using Jquery or Javascript

You need to use change() function after val() called. When you used val() of jquery in knockout context at that time you need to use below syntax, $('input[name="image_data"]').val(Data).change();
Rakesh Jesadiya's user avatar
11 votes

Magento 2.3.0 While edit UI component form data not filled up in custom module

If you use setting tags in ui-component. You need to add data return include fieldset. Example field "priority" will show "name='general['priority']' " Your loadedData in function getData() should ...
the light's user avatar
  • 708
10 votes

Magento 2.1 How do I create form component field custom depends on another field value?

The solution suggested by Magentix will throw an error from time to time when using initialize. It depends on the time it takes for your browser to render the components. In order to fix it you could ...
Mageinn's user avatar
  • 609
10 votes
Accepted

Magento 2: How to set radio input value using ui form

Finally i got the answer <field name="gender"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">[vendor]\[module]\Model\Config\...
Deexit Sanghani's user avatar
10 votes
Accepted

Magento 2 ui component form without database table

For this, Your Data Provider should be like <dataSource name="coupon_email_data_source"> <argument name="dataProvider" xsi:type="configurableObject"> <argument name=...
Smita Kagwade's user avatar
10 votes
Accepted

How to add a new field in cart price rule form in magento 2 backend?

Create file in your custom module app/code/Vendor/Module/view/adminhtml/ui_component/sales_rule_form.xml <?xml version="1.0" encoding="UTF-8"?> <form xmlns:xsi="http://www.w3.org/2001/...
Siarhey Uchukhlebau's user avatar
9 votes

Magento 2: How to add color picker in ui form

I added onChange event $(element).ColorPicker({ onSubmit: function(hsb, hex, rgb, el) { self.value(hex); $(el).ColorPickerHide(); },...
4epTuk's user avatar
  • 91
9 votes
Accepted

Magento 2 product_form.xml ovevride existing field

The correct way to update the product form in your module (using xml): app/code/Vendor/Module/view/adminhtml/ui_component/category_form.xml <?xml version="1.0" encoding="UTF-8"?> <form ...
Siarhey Uchukhlebau's user avatar
7 votes

Magento 2.1 How do I create form component field custom depends on another field value?

There's a lot of answers for this question, but most of them make either make assumptions on whether the uiRegistry is fully loaded, or use setTimeout to clear the call stack, and wait for the next ...
Erfan's user avatar
  • 3,107
7 votes
Accepted

Right way to create butons in uiComponent form in Magento 2

You can declare buttons inside the <argument name="data" xsi:type="array"> tag as this <item name="buttons" xsi:type="array"> <item name="back" xsi:type="string">[...
Marius's user avatar
  • 198k
7 votes

Ui form: Edit functionality: Image Preview in magento 2

Please try this one in your dataprovider, this is working code. <?php namespace OX\HomeSlider\Model; use Vendor\Module\Model\ResourceModel\Post\CollectionFactory; use Magento\Framework\App\...
Verdu's user avatar
  • 1,720
6 votes
Accepted

How to create custom modal ui form component with multiple fieldset and field

[UPDATED MY ANSWER] etc/adminhtml/di.xml Add modifier to add custom form modal <virtualType name="Vendor\Module\Ui\DataProvider\Item\Form\Modifier\Pool" type="Magento\Ui\DataProvider\Modifier\Pool"...
mrtuvn's user avatar
  • 3,263
6 votes

Magento 2: Add html instead of Ui from field?

Kindly update your code: <field name="statistics"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="sortOrder" ...
Sarfaraz bheda's user avatar
6 votes
Accepted

Magento 2 declaring modifier PHP Fatal Error: null given in $modifiers

Finally, this worked for me: changing Vendor/Module/etc/adminhtml/di.xml to <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:...
boat's user avatar
  • 121
6 votes
Accepted

Magento 2.2.5 : Add custom field in product attribute add form

Try via plugin method: CompanyName/ModuleName/etc/adminhtml/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:...
Abdul's user avatar
  • 9,662
6 votes
Accepted

Magento 2.3 : File Upload issue in UI Component Form

Please replace your UI Component with following code. Change imageUploader instead of fileUploader in your formElement. <field name="ffl"> <argument name="data" xsi:type="...
Aasim Goriya's user avatar
  • 5,374
6 votes
Accepted

Magento 2 : textarea height automatic set large in admin

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 ...
Chirag Patel's user avatar
  • 6,066
5 votes
Accepted

uiComponent Form. How to show data from DB table

My main problem that DataProvider::getData() function weren't executed was because it didn't know which row to populate. When I added /settings_id/1/ into an url then this function was called. And ...
Radek Radzik's user avatar
5 votes

Magento 2.1 How do I create form component field custom depends on another field value?

If you have got error like Field is Undefined when initialized field visibility, Use setTimeout() to load that depended fields: fieldDepend: function (value) { setTimeout(function(){ ...
Ronak Chauhan's user avatar
5 votes
Accepted

Magento 2 Field dependency in ui form

I have added a js component in the status field <field name="status"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> ...
Jancy Abraham's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible