6

I've added custom text box to source form using below code.

<field name="delivery_time" formElement="input" sortOrder="70">
            <settings>
                <dataType>text</dataType>
                <label translate="true">Delivery Time</label>
            </settings>
</field>

To save this field value I'm observing event controller_action_inventory_populate_source_with_data.

I tried below in observer,

$request = $observer->getEvent()->getRequest();
$requestData = $request->getParam('general', []);
$deliveryTime =  $requestData['delivery_time'];

I tried below code but it's not working,

$request->setParam('delivery_time',$deliveryTime);

$request->setPostValue('delivery_time',$deliveryTime);

I've created new column with delivery_time to table.

None of above is working Any idea ?

Any help will be appreciate. Thanks in advance.

10
  • Did you try this: $request->setDeliveryTime($deliveryTime);
    – Ravi Soni
    Mar 12, 2019 at 12:18
  • There's no method like 'setDeliveryTime' do it will return error with call to undefined method.....
    – anonymous
    Mar 12, 2019 at 12:33
  • are you sure this is a magento 2.3 version?
    – fmsthird
    Mar 19, 2019 at 4:20
  • Yes @magefms It's 2.3 CE and form is Sources under stores.
    – anonymous
    Mar 19, 2019 at 4:40
  • 1
    @magefms, Not little, Let me try again, I've added new field to source form, Under stores->Inventory->sources. Using xml file, and want to save field to DB table inventory_source where all other fields are getting stored that's it. What else you thing missing ! :)
    – anonymous
    Mar 19, 2019 at 6:02

1 Answer 1

1
+50

To save this you have to create extension attribute for your entity.

https://devdocs.magento.com/guides/v2.3/extension-dev-guide/attributes.html

Check above to know how to create those.

Than you can use in observer like, setter and getter methods like getDeliveryTime and setDeliveryTime.

Hope it will help to solve your issue.

Your Answer

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

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