# Disable "add existing" for a collection's related data

**URL:** <https://community.forestadmin.com/t/disable-add-existing-for-a-collections-related-data/2990>\
**Category:** Help me!\
**Created:** [July 27, 2021, 9:46am UTC](https://community.forestadmin.com/t/disable-add-existing-for-a-collections-related-data/2990 "2021-07-27T09:46:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cooki](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/cooki/32/2657_2.png) [@cooki](https://community.forestadmin.com/u/cooki)\
**Post date:** [July 27, 2021, 9:46am UTC](https://community.forestadmin.com/t/disable-add-existing-for-a-collections-related-data/2990/1 "2021-07-27T09:46:39Z")

</div>

Hey, I would like to not allow my users to add existing records and force them to create a new one, is there a way to achieve this ?

i.e: I would like to only show the "create a new " action.

 ![Screen Shot 2021-07-27 at 11.50.29 AM](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/e/e1e59ee2dfc20e0445005407822970e818288534.png)

Similarly, for another association (another related data), I would like to only allow users to add existing records to the association.

 ![Screen Shot 2021-07-27 at 11.48.01 AM](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/b/bd71fd28bb11d6d008d10dd7d72024aa0e880ca6.png)

Thanks !

---

<div class="post-metadata">

**Author:** ![cooki](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/cooki/32/2657_2.png) [@cooki](https://community.forestadmin.com/u/cooki)\
**Post date:** [July 27, 2021, 12:22pm UTC](https://community.forestadmin.com/t/disable-add-existing-for-a-collections-related-data/2990/2 "2021-07-27T12:22:44Z")

</div>

Can anyone answer me ?

---

<div class="post-metadata">

**Author:** ![anon39940173](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@anon39940173](https://community.forestadmin.com/u/anon39940173)\
**Post date:** [July 27, 2021, 12:41pm UTC](https://community.forestadmin.com/t/disable-add-existing-for-a-collections-related-data/2990/3 "2021-07-27T12:41:13Z")

</div>

Yes of course!  
Sorry for the delay.

The only ways to disable those buttons are to using the roles, but then the action will be forbidden in the whole app.

I’ll add a feature request to our internal tool

---

<div class="post-metadata">

**Author:** ![anon39940173](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@anon39940173](https://community.forestadmin.com/u/anon39940173)\
**Post date:** [July 27, 2021, 2:41pm UTC](https://community.forestadmin.com/t/disable-add-existing-for-a-collections-related-data/2990/4 "2021-07-27T14:41:54Z")

</div>

Another way to customize those actions would be to hide the default actions by configuring the relationships as “read-only” in the collection settings.

But it is not granular and you will disable both action.

Then, with both actions disabled, you would have to create a manual Smart action with a custom form to either create records or add an existing one.  
This should be feasible with Smart Action Hooks, but can be a lot of work.

I’m not sure that I get the structure of your database.

As I understand you have questions, and then, two many to many associations that link them with answers (depending on if they are required or not).  
Are answers reusable between questions?

Would it be feasible to do either of those solutions:

- If the answers are not reusable: replace those two relations by a single one to many relation between questions and answers, and then add a boolean column on answers depending on if they are required or not?
- If the answers are reusable: replace those two relations by a single many to many relation with a “required” column on the relation table

---

<div class="post-metadata">

**Author:** ![cooki](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/cooki/32/2657_2.png) [@cooki](https://community.forestadmin.com/u/cooki)\
**Post date:** [July 28, 2021, 10:17am UTC](https://community.forestadmin.com/t/disable-add-existing-for-a-collections-related-data/2990/5 "2021-07-28T10:17:40Z")

</div>

Hey @anon39940173, thanks for your thoughtful response, because the current data model is necessary for overall application logic, I cannot change the existing relationships, and thus decided to go the “ **Smart Action Form** ” route.

That being said, I would like to have a field be a reference to another collection, see image below:

 ![Screen Shot 2021-07-28 at 12.16.01 PM](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/7/76bbd5ad3c1a881f9a851faf4109332757717cf4.png)

I would like that field to be a “select” and not a text input field, is that possible ?  
This is the current code for that field:

```javascript
        {
          field: "answer-type",
          description: "The type of the answer.",
          type: "String",
          reference: "AnswerType.id",
          isRequired: true,
        }

```

Is that achievable ?

Thank you very much !

---

<div class="post-metadata">

**Author:** ![anon39940173](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@anon39940173](https://community.forestadmin.com/u/anon39940173)\
**Post date:** [July 28, 2021, 10:48am UTC](https://community.forestadmin.com/t/disable-add-existing-for-a-collections-related-data/2990/6 "2021-07-28T10:48:34Z")

</div>

You can change the default widget using the ‘widget’ property on the smart action form fields

```javascript
{
  field: "answer-type",
  description: "The type of the answer.",
  type: "String",
  reference: "AnswerType.id",
  isRequired: true,
  widget: 'belongsto select'
}

```

Fields can also be shown / hidden dynamically using “Smart action hooks” as per the doc.

---

<div class="post-metadata">

**Author:** ![cooki](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/cooki/32/2657_2.png) [@cooki](https://community.forestadmin.com/u/cooki)\
**Post date:** [July 28, 2021, 10:56am UTC](https://community.forestadmin.com/t/disable-add-existing-for-a-collections-related-data/2990/7 "2021-07-28T10:56:36Z")

</div>

@anon39940173  
amazing, thanks !
