How to specify a max value for number widgets dynamically?

Feature(s) impacted

Collections and the edit view

Observed behavior

I am unable to specify the maximum value that a number input can handle dynamically

Expected behavior

I’d like to specify the maximum value my number input can handle dynamically. I have a participants limit input that is not read-only and the participants limit is set by the environment variables of another micro-service. When a request is made from my Forest’s back office, a bridge is made to the specific micro-service whom handle it. The micro-service will then send a participant limit and I want to set this value as the maximum value of the input in the edit view.

How can I make it dynamically ?

Context

Please provide in this mandatory section, the relevant information about your configuration:

  • Project name: Back Office TR
  • Team name: the-ring.io
  • Environment name: Development

Hello @KamilH

It is currently not possible to customize frontend validators dynamically in the detail-view.

You can however

  • Create smartfields with logic to postprocess the data entered by the user.
  • Override the route to add validation from the agent

with a smartfield: How to format a field on the add form on forestadmin?

with a route override:

router.put(
  "/test/:recordId",
  permissionMiddlewareCreator.update(),
  (request, response, next) => {
    if (request.body.data.attributes.FIELD_NAME > 123) {
      response
        .status(400)
        .json({ errors: [{ detail: "The field is invalid" }] });
    }

    // Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#update-a-record
    next();
  }
);