How to add this to my custom widget at backend?
-
custom widget?? Could you please explain?– Navin BistaCommented Mar 2, 2018 at 8:57
-
i create a custom widget call bestselling product, now i want a multi category input field like this– user63384Commented Mar 2, 2018 at 9:00
-
Is it a widget you are creating or the module?– Navin BistaCommented Mar 2, 2018 at 9:06
-
my module of course– user63384Commented Mar 2, 2018 at 9:09
Add a comment
|
2 Answers
You need to create a category chooser for the Magento Admin Panel:
Backend configurations:
<field id="multi_category_chooser" translate="label" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Categories</label>
<frontend_model>[Vendor]\[Modul]\Block\Adminhtml\Category\Widget\[Chooser]</frontend_model>
Or
$fieldset->addField(
'multi_category_chooser',
'[Vendor]\[Modul]\Block\Adminhtml\Category\Widget\[Chooser]',
[
'name' => 'multi_category_chooser',
'label' => __('Categories'),
'title' => __('Categories'),
'required' => true
]
);
To Be Continued in below url
I hope this will help you.
You can try
$categories = $fieldsetData->addField(
'categories',
'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Category',
[
'name' => 'categories',
'label' => __('Categories'),
'required' => TRUE,
]
);
and adding < css src="Magento_Catalog::catalog/category-selector.css"/ > to your layout.
I haven't checked it but it worked for others.Please see this.
Hope it helps you. If it does, please accept the answer and vote it up, so that it could help others too.
Regards
-
i have checked this but really don't know how to do it, where should i put the code in? Commented Mar 2, 2018 at 9:32
-
You should add it to the admin form, basically "Package_name/Module_name/Adminhtml/Module_name/Edit/Tab/filename.php" Commented Mar 2, 2018 at 9:38
-
-
What variable you used? In above example its $fieldsetData but in your case it could be different? Did you find the file where you need to add that? Commented Mar 2, 2018 at 10:51