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

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.

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

Thanks !

Can anyone answer me ?

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

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

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:

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:

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

Is that achievable ?

Thank you very much !

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

{
  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.

@anon39940173
amazing, thanks !