Smart Fields
Please be sure of your agent type and version and pick the right documentation accordingly.
This is the documentation of the forest-express-sequelize and forest-express-mongoose Node.js agents that will soon reach end-of-support.
forest-express-sequelize v9 and forest-express-mongoose v9 are replaced by @forestadmin/agent v1.
Please check your agent type and version and read on or switch to the right documentation.
This is still the latest Ruby on Rails documentation of the forest_liana agent, you’re at the right place, please read on.
This is the documentation of the django-forestadmin Django agent that will soon reach end-of-support.
If you’re using a Django agent, notice that django-forestadmin v1 is replaced by forestadmin-agent-django v1.
If you’re using a Flask agent, go to the forestadmin-agent-flask v1 documentation.
Please check your agent type and version and read on or switch to the right documentation.
This is the documentation of the forestadmin/laravel-forestadmin Laravel agent that will soon reach end-of-support.
If you’re using a Laravel agent, notice that forestadmin/laravel-forestadmin v1 is replaced by forestadmin/laravel-forestadmin v3.
If you’re using a Symfony agent, go to the forestadmin/symfony-forestadmin v1 documentation.
Please check your agent type and version and read on or switch to the right documentation.
Smart Fields
What is a Smart Field?
A field that displays a computed value in your collection.

A Smart Field is a column that displays processed-on-the-fly data. It can be as simple as concatenating attributes to make them human friendly, or more complex (e.g. total of orders).
Creating a Smart Field
On our Live Demo, the very simple Smart Field fullname is available on the customers collection.
Very often, the business logic behind the Smart Field is more complex and must be asynchronous. To do that, please have a look at this section.
On our Live Demo, the very simple Smart Field fullname is available on the customers collection.
Very often, the business logic behind the Smart Field is more complex and must be asynchronous. To do that, please have a look at this section.
On our Live Demo, the very simple Smart Field fullname is available on the Customer collection.
Very often, the business logic behind the Smart Field is more complex and must interact with the database. Here’s an example with the Smart Field full_address on the Customer collection.
On our Live Demo, the very simple Smart Field fullname is available on the Customer collection.
Ensure the file app/forest/__init__.py exists and contains the import of the previous defined class :
Very often, the business logic behind the Smart Field is more complex and must interact with the database. Here’s an example with the Smart Field full_address on the Customer collection.
On our Live Demo, the very simple Smart Field fullname is available on the Customer model.
Very often, the business logic behind the Smart Field is more complex and must interact with the database. Here’s an example with the Smart Field full_address on the Customer model.
The collection name must be the same as the model name.

Updating a Smart Field
By default, your Smart Field is considered as read-only. If you want to update a Smart Field, you just need to write the logic to “unzip” the data. Note that the set method should always return the object it’s working on. In the example hereunder, the customer object is returned including only the modified data.
Working with the actual record can be done this way:
By default, your Smart Field is considered as read-only. If you want to update a Smart Field, you just need to write the logic to “unzip” the data. Note that the set method should always return the object it’s working on. In the example hereunder, the customer record is returned.
Working with the actual record can be done this way:
By default, your Smart Field is considered as read-only. If you want to update a Smart Field, you just need to write the logic to “unzip” the data. Note that the set method should always return the object it’s working on. In the example hereunder, the user_params is returned is returned including only the modified data.
By default, your Smart Field is considered as read-only. If you want to update a Smart Field, you just need to write the logic to “unzip” the data. Note that the set method should always return the object it’s working on. In the example hereunder, the customer object is returned including only the modified data.

Searching, Sorting and Filtering on a Smart Field
To perform a search on a Smart Field, you also need to write the logic to “unzip” the data, then the search query which is specific to your zipping. In the example hereunder, the firstname and lastname are searched separately after having been unzipped.

Filtering
This feature is only available on agents version 6.7+ (version 6.2+ for Rails).
To perform a filter on a Smart Field, you need to write the filter query logic, which is specific to your use case.
In the example hereunder, the fullname is filtered by checking conditions on the firstname and lastname depending on the filter operator selected.


Sorting
Sorting on a Smart Field is not natively supported in Forest Admin. However you can check out those guides:
Available Field Options
Here are the list of available options to customize your Smart Field:
field
string
The name of your Smart Field.
type
string
Type of your field. Can be Boolean, Date, Json,Dateonly, Enum, File, Number, ['String'] or String .
enums
array of strings
(optional) Required only for the Enum type. This is where you list all the possible values for your input field.
description
string
(optional) Add a description to your field.
isReadOnly
boolean
(optional) If true, the Smart Field won’t be editable in the browser. Default is true if there’s no set option declared.
isRequired
boolean
(optional) If true, your Smart Field will be set as required in the browser. Default is false.
Building Performant Smart Fields
To optimize your smart field performance, we recommend using a mechanism of batching and caching data requests.
Implement them using the DataLoader which is a generic utility to be used as part of your application's data fetching layer to provide a simplified and consistent API over various remote data sources.
Smart field declaration
Last updated
Was this helpful?