33
votes
Accepted
Magento 2 Add new field to Magento_User admin form
For adding image field, you can try using plugin and always try to avoid overwrite whole class.
Vendor/Module/etc/adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/...
28
votes
Accepted
How to make a form field readonly using ui-components?
Try to add the disabled parameter to the element like this:
<field name="is_active">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
...
17
votes
Accepted
Add WYSIWYG Editor to Block Form in Magento 2
Discovered I was missing the Config setting:
/**
* @var \Magento\Cms\Model\Wysiwyg\Config
*/
protected $_wysiwygConfig;
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \...
16
votes
Accepted
How to get all list of customer group?
I was able to get solution using the below code:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$groupOptions = $objectManager->get('\Magento\Customer\Model\ResourceModel\...
14
votes
Magento Add Condition Rule In A Custom Form in magento 2
To add a conditional field to the default model (and further utilize it for validating purposes), you will need to create a new model (or modify the existing one) that contains these fields.
app/...
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
$_File array empty in Magento 2 while Uploading file at admin form
It was my bad !!
I forgot to add
enctype'=>'multipart/form-data
You have to add following code while creating formFactory
$form = $this->_formFactory->create(
['data' => ...
13
votes
Accepted
Field comments in ui_component form
You should use notice:
<item name="notice" xsi:type="string" translate="true">
Full example:
<field name="name">
<argument name="data" xsi:type="array">
...
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 ...
11
votes
Magento 2:Store View in Ui Component Form
Add following code into your ui_component form
<field name="storeviews">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Magento\Cms\Ui\Component\...
11
votes
Accepted
How to add a color picker field in Admin form?
Never mind guys, I resolved the problem.
Step 1: app/code/Vendor/Module/Block/Adminhtml/Module/Edit/Tab/Main.php
//Replace your db field name with "color"
$field = $fieldset->addField(
...
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
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
Magento2 admin grid ui component form hide multiple fields based on php condition
Override getMeta function in your dataprovider and set value like this.
my form.xml
<fieldset name="fieldset_name">
<field name="attribute_id">
...
9
votes
How to get all list of customer group?
You can use the following class: Magento\Customer\Model\Customer\Source\Group.
It provides a toOptionArray method that you can use to get an array of customer groups
9
votes
Accepted
Magento 2 : Could not save admin form contents into the DB
Add the following code in your execute function of Save Controller (Module/Controller/Adminhtml/Example/Save.php)
public function execute()
{
$resultRedirect = $this->...
9
votes
Accepted
Input type number in admin edit form Magento 2
Try this code :-
$fieldset->addField(
'sorting_order',
'text',
array(
'name' => 'sorting_order',
'label' => __('Sort Order'...
9
votes
Accepted
How to set default text field value in form Magento 2
Try this
$fieldset->addField(
'customer_id',
'text',
[
'label' => __('Customer Id'),
'title' => __('Customer Id'),
'name' => 'customer_id',
...
8
votes
Accepted
Magento 2: How add dropdown in admin form?
Change Category class by following code:
namespace Book\Flip\Model\Source;
class Category implements \Magento\Framework\Option\ArrayInterface
{
/**
* Retrieve options array.
*
* @...
8
votes
Accepted
How to create and add Backend form to Custom admin grid in magento 2
If you just need to create an admin form, have a look at here.
https://www.pierrefay.com/magento2-training/form-component-backend-crud-admin.html
To create our Form, we will first create the ...
8
votes
Accepted
Magento 2 - Unable to add record in dynamic rows in admin product edit page
I found the issue. The issue is from the linking property "links". The links property is missed while adding more than one record. So the datascope configuration is most important for the &...
7
votes
Magento 2: how to delete image or file
The answer of RT is good, but we should not use the ObjectManager directly in the example.
The reason is here "Magento 2: to use or not to use the ObjectManager directly".
So better example is below:...
7
votes
Accepted
Magento 2 : Selected categories are not visible in edit form
In that case you need to modify getData function.
For edit category_ids value must be an array.Suppose category_ids value save in db as comma separated that means '7,9,22'. So when you edit this ...
7
votes
Accepted
Magento2 not getting post data from ui component phtml file
You have to just add
data-form-part="forrname_form" in your input filed
forrname_form it's must be similar with your ui form name
your code shold be like now:
<tr>
&...
7
votes
Accepted
Submit custom form in Magento 2.3 admin
Your controller should extend Magento\Backend\App\Action
and implements Magento\Framework\App\Action\HttpPostActionInterface,
also don't forget about ACL.
So should look something like this:
...
6
votes
How to set field value of form field in Magento 2
You have to add below code in form file
app\code\Vendor\ModuleName\Block\Adminhtml\ModuleName\Edit\Form.php
$model->setData('test', 'female');
Example of form file:
<?php
namespace ...
6
votes
Use of undefined constant CURLOPT_PROTOCOLS
You need to install php curl (apt-get install php5-curl or
apt-get install php7.0-curl if you useung php7 )
and restart your web server for apache is service apache2 restart
6
votes
Accepted
Magento 2 - admin form show textbox on dropdown change
For field dependency in admin form, try below code
$selectField = $fieldset->addField('select_field', 'select', array(
'label' => 'Show/Hide Selection',
'name' => 'select_field', ...
6
votes
Magento 2: How add dropdown in admin form?
I assume you found this out by now, but the xml in the form ui
<item name="options" xsi:type="string">Book\Flip\Model\Category\Attribute\Source\Category</item>
belongs under data as a ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
adminform × 551magento2 × 269
uicomponent × 116
adminhtml × 109
admin × 66
magento-1.9 × 58
magento-2.1 × 51
forms × 48
grid × 35
ui-form × 30
magento2.3 × 26
admin-panel × 22
module × 19
magento-1.8 × 18
magento-1 × 15
image-upload × 15
backend × 14
product × 13
magento2.2 × 13
blocks × 12
custom × 12
wysiwyg × 12
save × 12
magento-1.7 × 11
form-validation × 11