0

How can I add custom html renderer for my for element.

I need a text bux besides it a button which will call ajax when clicking on it to do some random work. How can I implement it.

here is my form field

<fieldset name="General">
            <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                            <item name="label" xsi:type="string"/>
                    </item>
            </argument>
            <field name="product_id">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="dataType" xsi:type="string">text</item>
                        <item name="label" translate="true" xsi:type="string">product_name</item>
                        <item name="formElement" xsi:type="string">input</item>
                        <item name="source" xsi:type="string">Import</item>
                        <item name="sortOrder" xsi:type="number">10</item>
                        <item name="dataScope" xsi:type="string">product_name</item>
                        <item name="validation" xsi:type="array">
                                <item name="required-entry" xsi:type="boolean">false</item>
                        </item>
                    </item>
                </argument>
            </field>
    </fieldset>
0

According to magento sample module you can set render following way:

<field name="color">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <!--component constructor-->
            <item name="component" xsi:type="string">Magento_SampleForm/js/form/element/color-select</item>
            <!--main template for form field that renders elementTmpl as a child template-->
            <item name="template" xsi:type="string">ui/form/field</item>
            <!--customized form element template that will show colors-->
            <item name="elementTmpl" xsi:type="string">Magento_SampleForm/form/element/color-select</item>
            <item name="label" xsi:type="string">Autumn colors</item>
            <item name="visible" xsi:type="boolean">true</item>
            <item name="dataType" xsi:type="string">text</item>
            <item name="formElement" xsi:type="string">input</item>
            <item name="source" xsi:type="string">sampleform</item>
        </item>
    </argument>
</field>

Following tag is responsible for custom template

<item name="elementTmpl" xsi:type="string">Magento_SampleForm/form/element/color-select</item>
| improve this answer | |
  • hey tnx mate. I was trying the same thing just mismatched my file locations. Any ways as now we create grid from ui_component is it also necessary to create a form in similar way as for magento 2 future aspects ? – Priyank Sep 30 '16 at 6:06
  • yes. of course. – Sohel Rana Sep 30 '16 at 7:47
  • @SohelRana Can you please help me here? magento.stackexchange.com/q/294109/68281 – Niket Oct 31 '19 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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