0

enter image description here

How to add this to my custom widget at backend?

4
  • custom widget?? Could you please explain? Mar 2, 2018 at 8:57
  • i create a custom widget call bestselling product, now i want a multi category input field like this
    – user63384
    Mar 2, 2018 at 9:00
  • Is it a widget you are creating or the module? Mar 2, 2018 at 9:06
  • my module of course
    – user63384
    Mar 2, 2018 at 9:09

2 Answers 2

2

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

Multiple Category Chooser

I hope this will help you.

0

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

4
  • i have checked this but really don't know how to do it, where should i put the code in?
    – user63384
    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" Mar 2, 2018 at 9:38
  • this not work at all
    – user63384
    Mar 2, 2018 at 10:06
  • 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? Mar 2, 2018 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.