I've created a form in the admin using UI components, so in my view/adminhtml/ui_component/[module]_[entity]_form.xml
I have the following:
<field name="configuration">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Configuration</item>
<item name="formElement" xsi:type="string">textarea</item>
<item name="source" xsi:type="string">form</item>
<item name="sortOrder" xsi:type="number">30</item>
<item name="dataScope" xsi:type="string">configuration</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
</argument>
</field>
Now I don't want this value to be a textarea
, but I want to create my own HTML magic in the backend for this value. This 'HTML Magic' will eventually be a lot of JS/KnockOut that under water still sends some hidden data when posting the form, so it needs to be part of the form. I tried adding a rendered by adding:
<item name="renderer" xsi:type="object">Vendor\Module\Block\Adminhtml\Renderer\Configurator</item>
But this still renders the textarea. Then I tried replacing the formElement
with a custom class like so:
<item name="formElement" xsi:type="object">Vendor\Module\Component\Form\Element\Configurator</item>
But then I get the error:
The requested component ("Vendor\Module\Component\Form\Element\Configurator") is not found. Before using, you must add the implementation.
So 2 questions here:
- Is this the right way to add a custom form element to an admin form? (and if so: how?)
- Regardless of anything: how can I add the implementation? I'm digging through the UI-module to see how they did it, but I can't find anything.
Best Answer
You can check the magento sample module they have provided