Pre-fill a form with data from a relationship
Last updated
Was this helpful?
Last updated
Was this helpful?
This example shows you how to implement a smart action form where input fields are pre-filled with data coming from a hasOne relationship.
Here a Movie hasOne
movieCharacteristic.
On the movies
collection, we want to implement a smart action to edit the characteristics of a movie.
To do so, a smart action called update-movie-characteristics
is defined with input fields corresponding to the fields of the movieCharacteristic
we want to edit. Their value is pre-filled to ensure the user is aware of their current value before editing them.
An admin backend running on forest-express-sequelize
This directory contains the movies.js
and movie-characteristics.js
files where the models are defined.
This directory contains the movies.js
file where the smart action update-movie-characteristics
is declared. We use the to pre-fill smart action forms.