# Access other fields value(data) in custom renderer

**URL:** <https://jsonforms.discourse.group/t/access-other-fields-value-data-in-custom-renderer/224>\
**Category:** General\
**Created:** [May 23, 2021, 5:53pm UTC](https://jsonforms.discourse.group/t/access-other-fields-value-data-in-custom-renderer/224 "2021-05-23T17:53:42Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [May 23, 2021, 5:53pm UTC](https://jsonforms.discourse.group/t/access-other-fields-value-data-in-custom-renderer/224/1 "2021-05-23T17:53:42Z")

</div>

Hi everyone, I have a form with a few dependent fields. I mean one field may change its behavior if the value of another field is equal to a special value. I need to access the value of other fields inside custom renderer. is it possible? how?

_[[original thread](https://spectrum.chat/jsonforms/general/access-other-fields-valuedata-in-custom-renderer~59f0fb45-76be-4868-a437-0d1bb7866122) by farshad-abb]_

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [May 24, 2021, 11:55am UTC](https://jsonforms.discourse.group/t/access-other-fields-value-data-in-custom-renderer/224/2 "2021-05-24T11:55:10Z")

</div>

Hi @farshad-abb(farshad-abb), you can access other fields in one of two ways:

- Use the `useJsonForms` hook which gives you access to the full JSON Forms context. Note that of course the regular context rules of React apply. So you should not change any data value directly here.

```auto
 import { useJsonForms } from '@jsonforms/react';
 ... 
 const ctx = useJsonForms();
 const wholeDataObject = ctx.core.data;

```

- Write your own version of the `withJsonFormsControlProps` HOC. In that HOC we determine the props for the renderer component by looking at the dispatched props and the JSON Forms context. You can just write an own one instead of using the one provided by JSON Forms. In there you can add any additional prop you like, i.e. also a prop pointing at the data you’re interested in.

---

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [May 24, 2021, 6:38pm UTC](https://jsonforms.discourse.group/t/access-other-fields-value-data-in-custom-renderer/224/3 "2021-05-24T18:38:11Z")

</div>

_[farshad-abb]_

@sdirix(sdirix) Thanks Stefan, it helped. I wish I could find these this information in documentation.

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [May 25, 2021, 6:40am UTC](https://jsonforms.discourse.group/t/access-other-fields-value-data-in-custom-renderer/224/4 "2021-05-25T06:40:52Z")

</div>

Feel free to [contribute](https://github.com/eclipsesource/jsonforms2-website) 😉

---

<div class="post-metadata">

**Author:** ![jdwit](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/jdwit/32/264_2.png) [@jdwit](https://jsonforms.discourse.group/u/jdwit)\
**Post date:** [May 5, 2022, 1:27pm UTC](https://jsonforms.discourse.group/t/access-other-fields-value-data-in-custom-renderer/224/5 "2022-05-05T13:27:04Z")

</div>

Hi sdirix, I need the exact same (access data of other form fields in a particular renderer) and I am using Vue. However I cannot find the useJsonForms hook in the Vue set of hooks. Is there another way of doing this? Thanks!

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [May 5, 2022, 2:37pm UTC](https://jsonforms.discourse.group/t/access-other-fields-value-data-in-custom-renderer/224/6 "2022-05-05T14:37:20Z")

</div>

Hi @jdwit,

in Vue you can `inject` the `jsonforms` object containing the same state as returned by the `useJsonForms()` hook in React.

---

<div class="post-metadata">

**Author:** ![felixholfelder](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/felixholfelder/32/781_2.png) [@felixholfelder](https://jsonforms.discourse.group/u/felixholfelder)\
**Post date:** [July 18, 2023, 1:05pm UTC](https://jsonforms.discourse.group/t/access-other-fields-value-data-in-custom-renderer/224/7 "2023-07-18T13:05:46Z")

</div>

Hi @sdirix ,  
I am also using JsonForms in my Vue/Nuxt project. I acutally don’t know where to get the `jsonforms` object from. I found an interface named `JsonFormsState` which contains such an object you described above. Is this the interface I should go for? And how should I `inject` it to my app?  
Best Regards

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [July 18, 2023, 1:09pm UTC](https://jsonforms.discourse.group/t/access-other-fields-value-data-in-custom-renderer/224/8 "2023-07-18T13:09:29Z")

</div>

Hi @felixholfelder,

See this [Vue guide](https://vuejs.org/guide/components/provide-inject.html) for provide/inject. [This is example code](https://github.com/eclipsesource/jsonforms/blob/d6f1fda00cdf9502c144b3706ebc7f555a8c6fee/packages/vue/vue/src/jsonFormsCompositions.ts#L164) where we use it within our bindings.

---

<div class="post-metadata">

**Author:** ![felixholfelder](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/felixholfelder/32/781_2.png) [@felixholfelder](https://jsonforms.discourse.group/u/felixholfelder)\
**Post date:** [July 18, 2023, 1:14pm UTC](https://jsonforms.discourse.group/t/access-other-fields-value-data-in-custom-renderer/224/9 "2023-07-18T13:14:50Z")

</div>

It worked thank’s a lot 🙂

---

<div class="post-metadata">

**Author:** ![Langhaus](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@Langhaus](https://jsonforms.discourse.group/u/Langhaus)\
**Post date:** [February 10, 2025, 3:58pm UTC](https://jsonforms.discourse.group/t/access-other-fields-value-data-in-custom-renderer/224/10 "2025-02-10T15:58:33Z")

</div>

Hi! Great support! I tried your vue guide for injection. I can access the error array, both when injecting your “jsonforms” provide, even my own provide of a customn ajv instance. In both cases, I cannot manage to make errors “responsive” in vue. I read in another thread that others had problems with responsivity in vue and the AJV instance?

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [February 10, 2025, 4:01pm UTC](https://jsonforms.discourse.group/t/access-other-fields-value-data-in-custom-renderer/224/11 "2025-02-10T16:01:55Z")

</div>

@Langhaus although you can access the `jsonforms` state, it’s not meant to be directly manipulated. If you want to modify the `errors` on the fly, you should use a [middleware](https://jsonforms.io/docs/middleware).
