Magento – Magento 2 – Add tree category selector on backend module

backendformsmagento2

I'm trying to create my custom form on a backend module, I need to allow the admin to select some categories, so I wanted to use the magento standard category selector, well I add my field in this way:

$fieldset->addField(
        'input_id',
        'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Category',
        [
            'name' => 'input_name',
            'label' => __('My label'),
            'title' => __('My title'),
            'required' => true
        ]
    );

then in the .xml of my custom module (where I call the block with the form) I also added this css in the head

<head>
    <title>
        Settings
    </title>
    <css src="Magento_Catalog::web/catalog/category-selector.css" />
</head>

In my module now I could find the input, but the css is not loaded (I get error 404 in the console log) and It not work fine.

I already tryed to clean the cache and run the deploy of static content, but I still get the same error.

If is possible I would like to know how to add a short description for each input to made easier to understand what they have to input.

Thank you.

Best Answer

Add css following way:

<head>
    <css src="Magento_Catalog::catalog/category-selector.css"/>
</head>
Related Topic