3

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

5

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.

  • Thanks for explanation. It works. I was just missing data-form-part attribute. – Sameer Bhayani Aug 19 '17 at 10:29
  • great to know that it helped you. your welcome – SyncTechnolab Aug 19 '17 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 '17 at 7:27
  • nice answer. worked perfectly. – Yau Thomas Jan 2 '18 at 7:17
  • glad to know it... – SyncTechnolab Jan 8 '18 at 16:14

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.