Drop Down Multi-select category Ui Component Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How to properly populate ui-select componentMagento 2.1 Create a filter in the product grid by new attributeMagento 2 Add new field to Magento_User admin formMagento 2 - Drop down Customer select listmagento 2 multiple values drop down dependencies?Ui-component form (Adding drop down field)in magento 2Magento2: Added drop-down in category filtration in Magento2Multi Select UI Field in user form magento2How to change the template of select (drop-down) in bundle products?Magento 2 How to remove default website checkbox checked while add new product?
Providing direct feedback to a product salesperson
How to keep bees out of canned beverages?
Can the van der Waals coefficients be negative in the van der Waals equation for real gases?
How to make an animal which can only breed for a certain number of generations?
A German immigrant ancestor has a "Registration Affidavit of Alien Enemy" on file. What does that mean exactly?
Knights and Knaves question
Why do people think Winterfell crypts is the safest place for women, children & old people?
How to mute a string and play another at the same time
How can I introduce the names of fantasy creatures to the reader?
What is the ongoing value of the Kanban board to the developers as opposed to management
What kind of equipment or other technology is necessary to photograph sprites (atmospheric phenomenon)
How to ask rejected full-time candidates to apply to teach individual courses?
What were wait-states, and why was it only an issue for PCs?
If gravity precedes the formation of a solar system, where did the mass come from that caused the gravity?
Married in secret, can marital status in passport be changed at a later date?
How do I deal with an erroneously large refund?
Why isn't everyone flabbergasted about Bran's "gift"?
Protagonist's race is hidden - should I reveal it?
Does traveling In The United States require a passport or can I use my green card if not a US citizen?
"Destructive force" carried by a B-52?
Why not use the yoke to control yaw, as well as pitch and roll?
/bin/ls sorts differently than just ls
What could prevent concentrated local exploration?
Can I ask an author to send me his ebook?
Drop Down Multi-select category Ui Component
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?How to properly populate ui-select componentMagento 2.1 Create a filter in the product grid by new attributeMagento 2 Add new field to Magento_User admin formMagento 2 - Drop down Customer select listmagento 2 multiple values drop down dependencies?Ui-component form (Adding drop down field)in magento 2Magento2: Added drop-down in category filtration in Magento2Multi Select UI Field in user form magento2How to change the template of select (drop-down) in bundle products?Magento 2 How to remove default website checkbox checked while add new product?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am using this code to create a multi-select category option in a form.
It saves the data in the table correctly but when I try to edit it, it shows the selected category name in the field but doesn't show a checkbox(checked) in the drop down list. Instead It shows the Default Category box checked.
<field name="category_id">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">MagentoCatalogUiComponentProductFormCategoriesOptions</item>
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Category</item>
<item name="componentType" xsi:type="string">field</item>
<item name="formElement" xsi:type="string">select</item>
<item name="component" xsi:type="string">Magento_Catalog/js/components/new-category</item>
<item name="elementTmpl" xsi:type="string">ui/grid/filters/elements/ui-select</item>
<item name="dataScope" xsi:type="string">category_id</item>
<item name="filterOptions" xsi:type="boolean">true</item>
<item name="showCheckbox" xsi:type="boolean">true</item>
<item name="disableLabel" xsi:type="boolean">true</item>
<item name="multiple" xsi:type="boolean">true</item>
<item name="levelsVisibility" xsi:type="number">1</item>
<item name="sortOrder" xsi:type="number">30</item>
<item name="required" xsi:type="boolean">true</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">false</item>
</item>
<item name="listens" xsi:type="array">
<item name="$ $.namespace .$ $.namespace :responseData" xsi:type="string">setParsed</item>
</item>
</item>
</argument>
</field>
Here is the screenshot.
magento2 uicomponent adminform drop-downs
add a comment |
I am using this code to create a multi-select category option in a form.
It saves the data in the table correctly but when I try to edit it, it shows the selected category name in the field but doesn't show a checkbox(checked) in the drop down list. Instead It shows the Default Category box checked.
<field name="category_id">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">MagentoCatalogUiComponentProductFormCategoriesOptions</item>
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Category</item>
<item name="componentType" xsi:type="string">field</item>
<item name="formElement" xsi:type="string">select</item>
<item name="component" xsi:type="string">Magento_Catalog/js/components/new-category</item>
<item name="elementTmpl" xsi:type="string">ui/grid/filters/elements/ui-select</item>
<item name="dataScope" xsi:type="string">category_id</item>
<item name="filterOptions" xsi:type="boolean">true</item>
<item name="showCheckbox" xsi:type="boolean">true</item>
<item name="disableLabel" xsi:type="boolean">true</item>
<item name="multiple" xsi:type="boolean">true</item>
<item name="levelsVisibility" xsi:type="number">1</item>
<item name="sortOrder" xsi:type="number">30</item>
<item name="required" xsi:type="boolean">true</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">false</item>
</item>
<item name="listens" xsi:type="array">
<item name="$ $.namespace .$ $.namespace :responseData" xsi:type="string">setParsed</item>
</item>
</item>
</argument>
</field>
Here is the screenshot.
magento2 uicomponent adminform drop-downs
add a comment |
I am using this code to create a multi-select category option in a form.
It saves the data in the table correctly but when I try to edit it, it shows the selected category name in the field but doesn't show a checkbox(checked) in the drop down list. Instead It shows the Default Category box checked.
<field name="category_id">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">MagentoCatalogUiComponentProductFormCategoriesOptions</item>
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Category</item>
<item name="componentType" xsi:type="string">field</item>
<item name="formElement" xsi:type="string">select</item>
<item name="component" xsi:type="string">Magento_Catalog/js/components/new-category</item>
<item name="elementTmpl" xsi:type="string">ui/grid/filters/elements/ui-select</item>
<item name="dataScope" xsi:type="string">category_id</item>
<item name="filterOptions" xsi:type="boolean">true</item>
<item name="showCheckbox" xsi:type="boolean">true</item>
<item name="disableLabel" xsi:type="boolean">true</item>
<item name="multiple" xsi:type="boolean">true</item>
<item name="levelsVisibility" xsi:type="number">1</item>
<item name="sortOrder" xsi:type="number">30</item>
<item name="required" xsi:type="boolean">true</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">false</item>
</item>
<item name="listens" xsi:type="array">
<item name="$ $.namespace .$ $.namespace :responseData" xsi:type="string">setParsed</item>
</item>
</item>
</argument>
</field>
Here is the screenshot.
magento2 uicomponent adminform drop-downs
I am using this code to create a multi-select category option in a form.
It saves the data in the table correctly but when I try to edit it, it shows the selected category name in the field but doesn't show a checkbox(checked) in the drop down list. Instead It shows the Default Category box checked.
<field name="category_id">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">MagentoCatalogUiComponentProductFormCategoriesOptions</item>
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Category</item>
<item name="componentType" xsi:type="string">field</item>
<item name="formElement" xsi:type="string">select</item>
<item name="component" xsi:type="string">Magento_Catalog/js/components/new-category</item>
<item name="elementTmpl" xsi:type="string">ui/grid/filters/elements/ui-select</item>
<item name="dataScope" xsi:type="string">category_id</item>
<item name="filterOptions" xsi:type="boolean">true</item>
<item name="showCheckbox" xsi:type="boolean">true</item>
<item name="disableLabel" xsi:type="boolean">true</item>
<item name="multiple" xsi:type="boolean">true</item>
<item name="levelsVisibility" xsi:type="number">1</item>
<item name="sortOrder" xsi:type="number">30</item>
<item name="required" xsi:type="boolean">true</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">false</item>
</item>
<item name="listens" xsi:type="array">
<item name="$ $.namespace .$ $.namespace :responseData" xsi:type="string">setParsed</item>
</item>
</item>
</argument>
</field>
Here is the screenshot.
magento2 uicomponent adminform drop-downs
magento2 uicomponent adminform drop-downs
edited Apr 18 at 12:16
Arshad Hussain
4571928
4571928
asked Apr 18 at 12:03
Ghulam.MGhulam.M
31211
31211
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I didn't used Data Provider
<?php
namespace VendorModuleModelSales;
use VendorModuleModelResourceModelSalesCollectionFactory;
use MagentoFrameworkAppRequestDataPersistorInterface;
/**
* Class DataProvider
*/
class DataProvider extends MagentoUiDataProviderAbstractDataProvider
/**
* @var MagentoCmsModelResourceModelBlockCollection
*/
protected $collection;
protected $dataPersistor;
protected $loadedData;
private $storeManager;
public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $salesCollectionFactory,
DataPersistorInterface $dataPersistor,
MagentoStoreModelStoreManagerInterface $storeManager,
array $meta = [],
array $data = []
)
$this->collection = $salesCollectionFactory->create();
$this->dataPersistor = $dataPersistor;
$this->storeManager = $storeManager;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
public function getData()
if (isset($this->loadedData))
return $this->loadedData;
$items = $this->collection->getItems();
/** @var MagentoCmsModelBlock $block */
foreach ($items as $block)
$form = $this->loadedData[$block->getId()] = $block->getData();
$form['category_id']=explode(',',$form['category_id']);
$data = $this->dataPersistor->get('sales');
if (!empty($data))
$block = $this->collection->getNewEmptyItem();
$this->loadedData[$block->getId()] = $block->getData();
$this->dataPersistor->clear('sales');
else
if ($items)
if ($block->getData('banner') != null)
$banner[$block->getSaleId()] = $form;
return $banner;
return $this->loadedData;
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f270657%2fdrop-down-multi-select-category-ui-component%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I didn't used Data Provider
<?php
namespace VendorModuleModelSales;
use VendorModuleModelResourceModelSalesCollectionFactory;
use MagentoFrameworkAppRequestDataPersistorInterface;
/**
* Class DataProvider
*/
class DataProvider extends MagentoUiDataProviderAbstractDataProvider
/**
* @var MagentoCmsModelResourceModelBlockCollection
*/
protected $collection;
protected $dataPersistor;
protected $loadedData;
private $storeManager;
public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $salesCollectionFactory,
DataPersistorInterface $dataPersistor,
MagentoStoreModelStoreManagerInterface $storeManager,
array $meta = [],
array $data = []
)
$this->collection = $salesCollectionFactory->create();
$this->dataPersistor = $dataPersistor;
$this->storeManager = $storeManager;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
public function getData()
if (isset($this->loadedData))
return $this->loadedData;
$items = $this->collection->getItems();
/** @var MagentoCmsModelBlock $block */
foreach ($items as $block)
$form = $this->loadedData[$block->getId()] = $block->getData();
$form['category_id']=explode(',',$form['category_id']);
$data = $this->dataPersistor->get('sales');
if (!empty($data))
$block = $this->collection->getNewEmptyItem();
$this->loadedData[$block->getId()] = $block->getData();
$this->dataPersistor->clear('sales');
else
if ($items)
if ($block->getData('banner') != null)
$banner[$block->getSaleId()] = $form;
return $banner;
return $this->loadedData;
add a comment |
I didn't used Data Provider
<?php
namespace VendorModuleModelSales;
use VendorModuleModelResourceModelSalesCollectionFactory;
use MagentoFrameworkAppRequestDataPersistorInterface;
/**
* Class DataProvider
*/
class DataProvider extends MagentoUiDataProviderAbstractDataProvider
/**
* @var MagentoCmsModelResourceModelBlockCollection
*/
protected $collection;
protected $dataPersistor;
protected $loadedData;
private $storeManager;
public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $salesCollectionFactory,
DataPersistorInterface $dataPersistor,
MagentoStoreModelStoreManagerInterface $storeManager,
array $meta = [],
array $data = []
)
$this->collection = $salesCollectionFactory->create();
$this->dataPersistor = $dataPersistor;
$this->storeManager = $storeManager;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
public function getData()
if (isset($this->loadedData))
return $this->loadedData;
$items = $this->collection->getItems();
/** @var MagentoCmsModelBlock $block */
foreach ($items as $block)
$form = $this->loadedData[$block->getId()] = $block->getData();
$form['category_id']=explode(',',$form['category_id']);
$data = $this->dataPersistor->get('sales');
if (!empty($data))
$block = $this->collection->getNewEmptyItem();
$this->loadedData[$block->getId()] = $block->getData();
$this->dataPersistor->clear('sales');
else
if ($items)
if ($block->getData('banner') != null)
$banner[$block->getSaleId()] = $form;
return $banner;
return $this->loadedData;
add a comment |
I didn't used Data Provider
<?php
namespace VendorModuleModelSales;
use VendorModuleModelResourceModelSalesCollectionFactory;
use MagentoFrameworkAppRequestDataPersistorInterface;
/**
* Class DataProvider
*/
class DataProvider extends MagentoUiDataProviderAbstractDataProvider
/**
* @var MagentoCmsModelResourceModelBlockCollection
*/
protected $collection;
protected $dataPersistor;
protected $loadedData;
private $storeManager;
public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $salesCollectionFactory,
DataPersistorInterface $dataPersistor,
MagentoStoreModelStoreManagerInterface $storeManager,
array $meta = [],
array $data = []
)
$this->collection = $salesCollectionFactory->create();
$this->dataPersistor = $dataPersistor;
$this->storeManager = $storeManager;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
public function getData()
if (isset($this->loadedData))
return $this->loadedData;
$items = $this->collection->getItems();
/** @var MagentoCmsModelBlock $block */
foreach ($items as $block)
$form = $this->loadedData[$block->getId()] = $block->getData();
$form['category_id']=explode(',',$form['category_id']);
$data = $this->dataPersistor->get('sales');
if (!empty($data))
$block = $this->collection->getNewEmptyItem();
$this->loadedData[$block->getId()] = $block->getData();
$this->dataPersistor->clear('sales');
else
if ($items)
if ($block->getData('banner') != null)
$banner[$block->getSaleId()] = $form;
return $banner;
return $this->loadedData;
I didn't used Data Provider
<?php
namespace VendorModuleModelSales;
use VendorModuleModelResourceModelSalesCollectionFactory;
use MagentoFrameworkAppRequestDataPersistorInterface;
/**
* Class DataProvider
*/
class DataProvider extends MagentoUiDataProviderAbstractDataProvider
/**
* @var MagentoCmsModelResourceModelBlockCollection
*/
protected $collection;
protected $dataPersistor;
protected $loadedData;
private $storeManager;
public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $salesCollectionFactory,
DataPersistorInterface $dataPersistor,
MagentoStoreModelStoreManagerInterface $storeManager,
array $meta = [],
array $data = []
)
$this->collection = $salesCollectionFactory->create();
$this->dataPersistor = $dataPersistor;
$this->storeManager = $storeManager;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
public function getData()
if (isset($this->loadedData))
return $this->loadedData;
$items = $this->collection->getItems();
/** @var MagentoCmsModelBlock $block */
foreach ($items as $block)
$form = $this->loadedData[$block->getId()] = $block->getData();
$form['category_id']=explode(',',$form['category_id']);
$data = $this->dataPersistor->get('sales');
if (!empty($data))
$block = $this->collection->getNewEmptyItem();
$this->loadedData[$block->getId()] = $block->getData();
$this->dataPersistor->clear('sales');
else
if ($items)
if ($block->getData('banner') != null)
$banner[$block->getSaleId()] = $form;
return $banner;
return $this->loadedData;
answered Apr 19 at 16:53
Ghulam.MGhulam.M
31211
31211
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f270657%2fdrop-down-multi-select-category-ui-component%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown