0

I'm using custom phtml to display some data in an admin Ui form tab, and I want to be able to have a custom input that would get sent to the controller when I hit 'save'

ui_form.xml

 <fieldset name="comments">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="label" xsi:type="string" translate="true">Comments</item>
            <item name="collapsible" xsi:type="boolean">false</item>
            <item name="canShow" xsi:type="boolean">true</item>
            <item name="sortOrder" xsi:type="string">1</item>
        </item>
    </argument>
    <container name="custom_tab_container">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="sortOrder" xsi:type="string">1</item>
            </item>
        </argument>
        <htmlContent name="html_content">
            <argument name="block" xsi:type="object">Path/To/My/Block/Rendering/Data</argument>
        </htmlContent>
    </container>

</fieldset>

What I want:

custom_template.phtml

<?php

/** @var $block Path/To/My/Block/Rendering/Data */
?>

<div id="custom_input_id">
    <input name="custom_input" value="default" />
</div>

Current result: enter image description here Right now everything renders like it should, except that the data from my custom input is not sent to the save controller. How can I make this work ?

0

Found out, I just needed to add a data-form-part="<name_of_ui_form_file>" to my input like so :

<input name="custom_input" value="default" data-form-part="custom_ui_form"/>

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.