Update modifiedData by injected components logic

System Information
  • **Strapi Versio **: 4
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

Hi.

I injected a custom component into the content-manager plugin as described in the documentation. There we can use usecmeditviewdatamanager() to get acces to the data with the modifiedData object.

But i want to modify that data object with my component’s logic and want to listen to the save action, to do further actions. How can i do that?

Thanks.

To update your data you can use the onChange method from the useCMEditViewDataManager Hook,

  const { modifiedData, onChange } = useCMEditViewDataManager();
onChange({
      target: { name: "name_of_field", value: "new value" },
    });```
2 Likes