Is it possible to show list of all possible values in dropdown when using Smart Action's form field with "reference"

Let’s take the following case:

actions: [{
    name: 'Create Post',
    fields: [{
      field: 'user',
      reference: "users.id",
      isRequired: true
    }]
}]

Expected behavior

In Smart Action, when I set a field with reference: users.id, then the options for this field are shown only when I start typing something on this user field. That is, only after querying I am getting the list of users.

Is it possible to get the list of users during form load itself and display it in a dropdown so that searching can be avoided?

Actual behavior

As mentioned above, only when I start typing something the users are getting queried and shown in the form.

Failure Logs

None

Hi @Shriram_Balakrishnan !
Can you share a video (via loom for example) of your smart action so I can better understand what it is you are trying to accomplish ?

Hi @Shriram_Balakrishnan,

Did you try to set a dropdown widget doing so:

actions: [{
    name: 'Create Post',
    fields: [{
      field: 'user',
      reference: "users.id",
      isRequired: true,
      widget: 'dropdown'   
  }]
}]

Hi @arnaud,

I tried this now for Subject field in my form. But the form breaks.Here is the screenshot.

And I am getting JS error in the console.

vendor-8c57d7a635cd94d11cc3787ed4a841dd.js:24960 TypeError: Cannot read property 'get' of undefined
    at n.isFeatureCompatible (client-34db568df823589eccb7aa0fccb83857.js:6324)
    at n.initializeQueryParams (client-34db568df823589eccb7aa0fccb83857.js:4524)
    at n.init (client-34db568df823589eccb7aa0fccb83857.js:4522)
    at n [as init] (vendor-8c57d7a635cd94d11cc3787ed4a841dd.js:3462)
    at g (vendor-8c57d7a635cd94d11cc3787ed4a841dd.js:3367)
    at Function.e.create (vendor-8c57d7a635cd94d11cc3787ed4a841dd.js:3379)
    at e.n.create (vendor-8c57d7a635cd94d11cc3787ed4a841dd.js:1806)
    at r.i.create (vendor-8c57d7a635cd94d11cc3787ed4a841dd.js:2158)
    at Object.evaluate (vendor-8c57d7a635cd94d11cc3787ed4a841dd.js:4519)
    at e.t.evaluate (vendor-8c57d7a635cd94d11cc3787ed4a841dd.js:4373)

Please note that I am using Smart Action’s fields here.

Context:

  • Package Version: 6.2.1
  • Express Version: 4.16.4
  • Sequelize Version: 5.15.2
  • Database Version: MySQL 5.7
  • Project Name: xs-library

My bad @Shriram_Balakrishnan,

This is what you need:

actions: [{
    name: 'Create Post',
    fields: [{
      field: 'user',
      reference: "users.id",
      isRequired: true,
      widget: 'belongsto select'   
  }]
}]

Works perfectly! Thanks for the quick response @arnaud

Also, can you update where these details are mentioned in the docs?

Update1:

I have 2 questions:

  1. Can you update where these details are mentioned in the docs?
  2. Is it possible to have the select box typeable? If the drop down has a big list, it would be difficult to scroll and find the required element. So typeable select box (that helps in searching) will be of great help to the users.