3

I am on the edit page with the following url:

https://local.magento/admin/hello_test/shipping/edit/shippingmethod_id/1/key/df70da11cddd2ee1c41aa67a8cbccf6d9403207740547719560dec30a3fd9ceb/

, where I loaded a custom grid. When I want to edit the price column and press the save button, I would like to pass to the ajax url an extra paramater, from the UI component XML.

enter image description here

This is what I tried:

    <columns name="my_columns">
        <settings>
            <editorConfig>
                <param name="selectProvider" xsi:type="string">custom name</param>
                <param name="enabled" xsi:type="boolean">true</param>
                <param name="indexField" xsi:type="string">entity_id</param>
                <param name="clientConfig" xsi:type="array">
                    <item name="saveUrl" xsi:type="url" path="hello_test/Shipping/inlineEdit">
                        <param name="shippingmethod_id">{i would like here to include the shippingmethod_id value from my edit page url}</param>
                    </item>
                    <item name="validateBeforeSave" xsi:type="boolean">false</item>
                </param>
            </editorConfig>
....

In the <param name="shippingmethod_id"> i can include static values(and it works), but i would like to include the value of the shippingmethod_id from the edit page url . Is that possible ? :)

Thnx

1 Answer 1

4

To add dynamic parameters to the url you can use many approaches, depending on your case:

  1. Modify url in your dataprovider implementation \Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface::getMeta
  2. Modify url in component custom class (extending from \Magento\Ui\Component\Listing\Columns)
  3. Modify js component

But we have ability to pass all current url params to new url during url generation using param _current. So in your case the easiest way - add param _current to url element

<item name="saveUrl" xsi:type="url" path="hello_test/Shipping/inlineEdit">
    <param name="_current">true</param>
</item>
4
  • Hmm .adding the <param name="_current" xsi:type="boolean">true</param> part Element 'param', attribute '{http://www.w3.org/2001/XMLSchema-instance}type': The type definition 'boolean', specified by xsi:type, is blocked or not validly derived from the type definition of the element declaration. Commented Nov 18, 2019 at 18:57
  • I removed this part: xsi:type="boolean" and it works. Not sure why :) Can you update your post with this feedback ? , so i can accept your answer Commented Nov 18, 2019 at 19:27
  • @AttilaNaghi Yes, sure. I have updated answer
    – Max
    Commented Nov 19, 2019 at 8:17
  • Kudos for the solution @Max Commented Apr 23, 2023 at 14:06

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.