Display issue with nested fields in Forest Admin after updating Mongoose and schema

Feature(s) impacted

Nested fields display in Forest Admin collections

Observed behavior

Since recent updates, the letter_params field is no longer displayed as a structured object with individual subfields in the Forest Admin UI. Instead, it appears as a flat JSON block.

Expected behavior

letter_params should be rendered in the UI as a structured and readable set of subfields, as it was prior to the updates. Each nested property (e.g. description, postage_type, etc.) should be visible and editable individually.

Failure Logs

No relevant failure logs or errors observed in the backend or browser console. The issue appears to be a UI rendering regression rather than a runtime error.

Context

  • Project name: MySendingBox
  • Environment name: Staging (reproducible in other environments as well)
  • Database type: MongoDB
  • Recent changes made on your end if any: * * Upgraded
    • Mongoose** from version 5.13.22 to 7.8.7
    • Upgraded forest-express-mongoose from 9.3.25 to 9.6.0
    • Updated the GroupedSentSchema Mongoose model to replace a Mixed type:
export const GroupedSentSchema: Record<string, any> = {
  ...
  letter_params: { type: Schema.Types.Mixed },
  ...
}

with a proper nested schema:

export const GroupedSentSchema: SchemaDefinition<IGroupedSentModel> = {
  ...
  letter_params: LetterParamsSchema,
  ...
}

where LetterParamsSchema is

export const LetterParamsSchema: SchemaDefinition<ILetterParams> = {
  description: String,
  expected_sending_date: Date,
  ...
  postage_type: {
    type: String,
    enum: ['ecopli', 'verte', 'prioritaire', 'suivie', 'lr', 'lrar', 'email', ...],
    default: 'ecopli',
  },
  ...
}

Hi @sylvain1 :waving_hand: welcome to our community.
It seems that when you have updated the lettersParamsSchema, a level of nested object was added and the widget you see before does not support >1 nested props.

To illustrate

letter_params: {
  description: String
} // is ok

letter_params: {
  description: String
  from: {
    address_city: String
  }
} // is not

You can probably deal with flatten nested field configuration

Let me know if that help.

Thank you for your quick response.

I updated the lettersParamsSchema, but in the database, there is no difference between before and after the modification. Why was Forest able to display the nested fields correctly before? Was letter_params already treated as a nested structure back then?

Your suggestion partially solves the issue — the fields are now visible individually, which is a good step forward.

However, I’d like all these fields to be grouped together under a titled section. Right now, they are not labeled, and they don’t even appear next to each other in the interface, which makes it harder to understand their context.

Thanks again for your help!

Because, you added an additional props on your schema, here from, who make your object have >1 nested level.

Anyway, you can use the JSON widget to deal with your original json field and keep it under the letter params label.

Or if you want to keep the flatten mode, you can reorganise field to put them next to each other, or use a summary view with section.

Hi,
Thanks, this solution works on the summary page.
However, is there any way to improve the display on the detail page?

Also, I don’t quite understand how Forest is able to show this display when I don’t specify the schema, but isn’t able to do so afterwards.
Is there a technical reason behind this behavior?

Thanks in advance for your help!