How to obtain all fields values in plugin?

System Information
  • Strapi Version: 3.5.4
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

Hello, I’m writing a plugin with a custom type field.
To do it I’m simply creating new plugin, make components directory and write a new component.
All is working - but I’m need to obtain values from all strapi fields in my component.

For example - I’m need to obtain Name value (=asd)
I’m see strapi source and see - that all components wrapped to EditViewDataManagerProvider

I’m try:

import useDataManager from "strapi-plugin-content-manager/admin/src/hooks/useDataManager";
const dataManager = useDataManager();

But dataManager is undefined.

I’m try redux:

import { useSelector } from "react-redux";
const data2 = useSelector((state) => state);
  console.log("useSelector : ", data2);

but data2 don’t contain any values from another fields.

My attempts in 05_01_debug branch.

I need to realize “conditional field” - that value depends on over fields.
Please, advise me on how I can obtain the values of another field.

I was able to access the content of all fields using this technic:
Copy original strapi Inputs component from strapi-plugin-content-manager to :

Add at the top Inputs/index.js

import EditViewDataManagerContext from "../../contexts/EditViewDataManager";

before return write:
const context = React.useContext(EditViewDataManagerContext);

and pass to InputsIndex props this data:

          modifiedData: context.modifiedData,
          initialData: context.initialData,

I’m try to use this technic in my plugin component:
But after call this code inside local plugin:

const context = React.useContext(EditViewDataManagerContext);

I’m recieve : context is undefined.

Can anybody, please, explain to me why components in local plugin don’t access EditViewDataManagerContext ?

In extensions/content-manager/admin/src/components/RepeatableComponent/DraggedItem/index.js I get the value of the field with const value = get(modifiedData, keys, null);


modifiedData is const {modifiedData} = useDataManager();
keys is const keys = ${componentFieldName}.${name};
and obviously get is from lodash.

Ok, I’ve noticed now that you want to get all fields data when you’re in a plugin.

There’s a hook for that:

import { useContentManagerEditViewDataManager } from 'strapi-helper-plugin';

const { modifiedData } = useContentManagerEditViewDataManager()

    useEffect(() => {

    }, [modifiedData])