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">
...
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="...
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">
<...
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 ...
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:...
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 ...
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 ...
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 ...
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">
...
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">
<...
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();
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 ...
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 ...
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\...
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=...
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/...
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();
},...
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 ...
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 ...
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">[...
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\...
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"...
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" ...
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:...
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:...
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="...
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 ...
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 ...
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(){
...
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">
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
ui-form × 197magento2 × 130
uicomponent × 109
adminform × 30
magento2.3 × 17
magento-2.1 × 15
admin × 15
magento2.2 × 15
adminhtml × 12
magento2.2.2 × 12
grid × 10
form-validation × 8
php × 7
image-upload × 7
custom-field × 7
javascript × 6
magento2.3.0 × 5
fieldsets × 5
product × 4
checkout × 4
category × 4
knockoutjs × 4
forms × 4
ui × 4
image-preview × 4