Zend certified PHP/Magento developer

Add a dynamic not for product attribute in the adminhtml

I’m trying to add a dynamic not based on the attribute-set besides the price field in Magento 2.

After a lot of research, I’ve tried using PHP modifiers in UI components, and depending on the Container component without any fields I was able to produce the following code:

Vendor/Module/etc/adminhtml/di.xml file content

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool" type="MagentoUiDataProviderModifierPool">
        <arguments>
            <argument name="modifiers" xsi:type="array">
                <item name="vendor_module_example_modifier" xsi:type="array">
                    <item name="class" xsi:type="string">VendorModuleUiDataProviderProductFormModifierExampleModifier</item>
                    <item name="sortOrder" xsi:type="number">200</item>
                </item>
            </argument>
        </arguments>
    </virtualType>
</config>

VendorModuleUiDataProviderProductFormModifierExampleModifier

<?php

namespace VendorModuleUiDataProviderProductFormModifier;


use MagentoCatalogUiDataProviderProductFormModifierAbstractModifier;
use MagentoFrameworkStdlibArrayManager;

class ExampleModifier extends AbstractModifier
{
    private ArrayManager $arrayManager;

    /**
     * @param ArrayManager $arrayManager
     */
    public function __construct(
        ArrayManager $arrayManager
    ) {
        $this->arrayManager = $arrayManager;
    }

    public function modifyData(array $data)
    {
        return $data;
    }

    public function modifyMeta(array $meta)
    {
        $containerPath = $this->arrayManager->findPath(static::CONTAINER_PREFIX . MagentoCatalogApiDataProductAttributeInterface::CODE_PRICE, $meta, null, 'children');

        $meta = $this->arrayManager->merge($containerPath, $meta, [
            'children' => [
                'price_recommender' => [
                    'arguments' => [
                        'data' => [
                            'config' => [
                                'componentType' => 'container',
                                'label' => false,
                                'text' => __('<p>this is something to show</p>'),
                                'template' => 'ui/form/components/complex',
                            ]
                        ]
                    ]
                ]
            ]
        ]);

        return $meta;
    }
}

But I got the following error in the console, and it’s not showing the text.

Uncaught ReferenceError: Unable to process binding “foreach: function(){return elems }”
Message: Unable to process binding “if: function(){return !$data.additionalForGroup }”
Message: Unable to process binding “if: function(){return visible() }”
Message: visible is not defined
at if (eval at createBindingsStringEvaluator (knockout.js:2982), :3:55)
at ko.computed.disposeWhenNodeIsRemoved (knockout.js:4381)
at Function.evaluateImmediate_CallReadThenEndDependencyDetection (knockout.js:2173)
at Function.evaluateImmediate_CallReadWithDependencyDetection (knockout.js:2140)
at Function.evaluateImmediate (knockout.js:2101)
at Object.ko.computed.ko.dependentObservable (knockout.js:1954)
at init (knockout.js:4380)
at knockout.js:3358
at Object.ignore (knockout.js:1470)
at knockout.js:3357

I’ve searched about the error and found nothing to help me, I’ve tried the base example for the modifier using the select box and it works fine, now I’m really stuck with this error, and all changes not fixing the issue.

I really appreciate your help so much.