Is it possible to handle dom event on a form field?

Hello there,
I have an address field on a form. I want to be able to perform an api request when typing value on this field in order to dynamically set other fields like state, zipcode, country, etc.

Is it possible to make that with forestadmin ? Is it possible to handle dom event on form field in forestadmin ?


We got the same use case, and we use ‘onChange’ hook

Our smart action field :

  field: 'Adresse complète',
  type: 'String',
  isRequired: true,
  hook: 'onAddressChange'

And on the smart action hook section, we perform request and feed, in our case an enum field, with the returned values :

hooks: {
  change: {
    onAddressChange: async ({ fields, changedField }) => {
      if (changedField.value === '') return fields;
      const address = await getAddressSuggestions(changedField.value);
      fields[4].isReadOnly = false;
      fields[4].enums = address;
      return fields;
1 Like

Hello @Joel_Alexandre_Khang ,

Indeed as @Justin_Martin said, you can do it using smart actions Use a Smart Action Form - Developer guide :slight_smile:

1 Like

Thank you for your help guys