# How to get control of add button in jsonforms

**URL:** <https://jsonforms.discourse.group/t/how-to-get-control-of-add-button-in-jsonforms/296>\
**Category:** General\
**Created:** [July 21, 2021, 12:59am UTC](https://jsonforms.discourse.group/t/how-to-get-control-of-add-button-in-jsonforms/296 "2021-07-21T00:59:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dijadhav](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/dijadhav/32/93_2.png) [@dijadhav](https://jsonforms.discourse.group/u/dijadhav)\
**Post date:** [July 21, 2021, 12:59am UTC](https://jsonforms.discourse.group/t/how-to-get-control-of-add-button-in-jsonforms/296/1 "2021-07-21T00:59:31Z")

</div>

Hello,  
I have a property of type array in my jsonforms. I want the control of Add Button. How can i get it?  
Thanks  
Dipak

---

<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 21, 2021, 9:21am UTC](https://jsonforms.discourse.group/t/how-to-get-control-of-add-button-in-jsonforms/296/2 "2021-07-21T09:21:53Z")

</div>

Hi @dijadhav, you have to write a custom renderer for this. Your custom renderer can just wrap the existing one but provide your own implementation of `addItem`, all the other props can stay the same. I would like to recommend taking a look at our [Reusing existing controls](https://jsonforms.io/docs/tutorial/custom-renderers#reusing-existing-controls) guide.

---

<div class="post-metadata">

**Author:** ![dijadhav](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/dijadhav/32/93_2.png) [@dijadhav](https://jsonforms.discourse.group/u/dijadhav)\
**Post date:** [July 21, 2021, 10:26am UTC](https://jsonforms.discourse.group/t/how-to-get-control-of-add-button-in-jsonforms/296/3 "2021-07-21T10:26:04Z")

</div>

Thanks @ sdirix for help.

---

<div class="post-metadata">

**Author:** ![james-morris](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/james-morris/32/833_2.png) [@james-morris](https://jsonforms.discourse.group/u/james-morris)\
**Post date:** [August 26, 2021, 4:55pm UTC](https://jsonforms.discourse.group/t/how-to-get-control-of-add-button-in-jsonforms/296/4 "2021-08-26T16:55:13Z")

</div>

I did something similar to the listWithDetail renderer so that when you added a new item to the array it auto selects the new item:  
I did so by replacing the existing listWithDetail with a custom one and adding a new addItem function:

```auto
    const handleAddItem = useCallback(
        (p: string, value: any) => () => {
            addItem(p, value)();
            setSelectedIndex(data)
        },
        [addItem])

```

and then replacing the place where `addItems` is used with my new function `handleAddItem`
