Reading list Switch to dark mode

    How To Pass External Input Field Value With Existing Ui Form – Magento2

    Updated 19 November 2016

    We have already learned how to create ui component form in magento2.
    See these blogs for more details.
    Create Ui Form In Magento2 – Part 1
    Create Ui Form In Magento2 – Part 2
    In this blog we will see how to pass external input field value with ui component form in magento2.
    If you will try to pass some additional input field value with ui form, you will not get the field value in controller or observer.
    You will only get data of those fields which you define in ui form xml.
    But there is a way in magento2. You can pass input field value to ui form without defining it in ui form xml.

    How to pass external input field value with ui component form

    Its very simple. You just need to set a attribute value ‘data-form-part‘. Set ui form name in ‘data-form-part‘.

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

    Here i set ‘product_form‘ because i want to pass values in product ui form.
    You can set any ui form name.
    Now if you will submit form you will get data in controller where you are submitting this form.
    So Using this approach you can pass any external input element value with ui form.

    Also if you want full source code of how to create ui form, then you can download it from git.
    click here to download it from git.

    If you have any query or issue, comment below.

    Searching for an experienced
    Magento 2 Company ?
    Find out More
    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    1 comments

  • Vaisaga
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home