5

I am developing a module using ui_form. I have developed ui_form and on submit it post all fields except custom html fields.

For example:

<container name="pl_labelposition" >
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="sortOrder" xsi:type="number">30</item>
                <item name="label" xsi:type="string" translate="true">Label Position</item>
            </item>
        </argument>
        <htmlContent name="html_content">
            <argument name="block" xsi:type="object">Company\Module\Block\Adminhtml\ProductLabel\Edit\LabelPosition</argument>
        </htmlContent>
    </container>

I also use conditions of sales rules:

        <container name="conditions_apply_to" >
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="sortOrder" xsi:type="number">10</item>

            </item>
        </argument>
        <htmlContent name="html_content">
            <argument name="block" xsi:type="object">Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Conditions</argument>
        </htmlContent>
    </container>

Could you help me to resolve this problem? I am not able to submit such fields to controller. How can i use in controller?

Help will be appreciated

Thank You in Advance

1 Answer 1

14

In your block create

protected $_template = 'Company_Module::labelposition.phtml';

now, make labelposition.phtml and add your html field with attribute data-form-part="formname".

Here the formname must be name of your uiform like <uiComponent name="product_form"/>.

e.g.

<input type="text" data-form-part="product_form" name="test" value="Hello World">

You will get the value of this field.

7
  • Thanks for explanation. It works. I was just missing data-form-part attribute. Aug 19, 2017 at 10:29
  • great to know that it helped you. your welcome Aug 19, 2017 at 10:30
  • With e.g <input type="checkbox" data-form-part="product_form" name="test[]" value="Hello World"> <input type="checkbox" data-form-part="product_form" name="test[]" value="Hello World Two">. it not submit true.
    – xanka
    Nov 7, 2017 at 7:27
  • nice answer. worked perfectly.
    – Yau Thomas
    Jan 2, 2018 at 7:17
  • glad to know it... Jan 8, 2018 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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