Define display names via server side

This is more of a question rather than a feature or a bug. I already have a “Readable Name” for each column in my other backend code, which uses the same underlying database.

Is there a way for me to define and lock display names on the forest admin server code? So that I can just code it up all at bulk rather than changing it individually from UI.

Hi @BK42,

Is there a way for me to define and lock display names on the forest admin server code? So that I can just code it up all at bulk rather than changing it individually from UI.

I’m not sure to perfectly get what you want here.

Sequelize allow you to set “aliases” on column, and you should be able to use it on your lumber backend code.

Here is an example:

  const CarPart = sequelize.define('carPart', {
    myVeryCustomPartName: { // The backend name of the field, can be used in your code
      type: DataTypes.STRING,
      field: 'partname', // The database field name
    },
  }, {
    tableName: 'CarPart',
    timestamps: false,
    schema: process.env.DATABASE_SCHEMA,
  });

Then, if I log the request body in a route

// Create a Car Part
router.post('/carPart', permissionMiddlewareCreator.create(), (request, response, next) => {
  console.log(request.body)
  // Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#create-a-record
  next();
});

I’m getting this result

By default, the UI will use the alias name instead of the column name you are used to. In the previous example, my UI looks like

image

Since I’m not perfectly sure to have answer to your question, just let me know :pray:

2 Likes

That might actually work very well. Thank you :pray: