# Linked fields in JsonForms

**URL:** <https://jsonforms.discourse.group/t/linked-fields-in-jsonforms/972>\
**Category:** General\
**Created:** [August 23, 2022, 5:35pm UTC](https://jsonforms.discourse.group/t/linked-fields-in-jsonforms/972 "2022-08-23T17:35:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohan.thakare](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohan.thakare](https://jsonforms.discourse.group/u/rohan.thakare)\
**Post date:** [August 23, 2022, 5:35pm UTC](https://jsonforms.discourse.group/t/linked-fields-in-jsonforms/972/1 "2022-08-23T17:35:17Z")

</div>

Hi Team,

We have schema, which contains 2 fields but the data in both fields should be in sync, so do we have any provision like linked fields  
So we have schema like below, and name field is coming twice one at root second inside config, but what we want in data is both fields should be present and data should be in sync, update made in one field should reflect in second field as well

```auto
{
    "properties": {
      "name": {
            "type": "string",
            "description": "Name field",
            "x-path": "../config/name"
        },
        "config": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string",
                    "description": "Name field"
                },
                "title": {
                    "type": "string",
                    "description": "title field"
                }
            }
        }
    }
}

```

---

<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:** [August 24, 2022, 6:39pm UTC](https://jsonforms.discourse.group/t/linked-fields-in-jsonforms/972/2 "2022-08-24T18:39:11Z")

</div>

Hi @rohan.thakare,

First I would think about whether this is really necessary. Seems weird to duplicate data. If it’s just about visuals, then you can accomplish this via the UI Schema. When pointing two or more controls to the same data they will automatically be synced. Or just use the “inner” property at form-time and then duplicate it after the fact when you need to talk to some other API.

Of course I don’t know about your requirements, so in case you need to handle it like this then you have two different approaches available:

- Sync the data **within** JSON Forms. In that case you could register custom renderers (in this case for `name` and `config/name`) which would then not only modify _their_ data but also the other path. The information in the schema shown is sufficient to implement this generically with some analysis (e.g. check for all properties whether some other `x-path` points to it). For implementation you could probably reuse all existing primitive renderers by wrapping them and just handing over a specialized `handleChange` method.
- Sync the data **outside** of JSON Forms. In that case you would listen to the data change events coming from JSON Forms and then modify the `data` before feeding it back to JSON Forms. This makes especially sense when you already have this logic in place somewhere else in your app. The downside is that you will rerender the form twice for all these cases, however that should usually not be noticable
