You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A list of models - Each model is associated to a Make
A list of Variants - To create a Variant, we should select a Make and Model.
Current behaviour:
In Variant's UI I am getting list of all the models instead of getting a filtered list of models based on my make selection.
Expected behaviour:
Once I select a Make, I should get a list of associated models.
Is there a way/sample which I can refer to create such relationships in UI with customized queries for subsequent fields rather than showing the whole list in a dropdown.
Here's the sample schema for Variant.
`import { list } from '@keystone-6/core';
import { allowAll } from '@keystone-6/core/access';
import {
text,
relationship,
password,
timestamp,
} from '@keystone-6/core/fields';
import { stars } from '../fields/2-star-field';
export const Variant = list({
access: allowAll,
// this is the fields for our User list
fields: {
make: relationship({
ref: 'Make',
many: false,
}),
model: relationship({
ref: 'Model.variant',
many: false
}),
name: text({ validation: { isRequired: true } }),
rating: stars({
ui: {
description: 'A star rating, with a scale of 5',
},
}),
createdAt: timestamp({
// this sets the timestamp to Date.now() when the user is first created
defaultValue: { kind: 'now' },
}),
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I've this use case:
Current behaviour:
In Variant's UI I am getting list of all the models instead of getting a filtered list of models based on my make selection.
Expected behaviour:
Once I select a Make, I should get a list of associated models.
Is there a way/sample which I can refer to create such relationships in UI with customized queries for subsequent fields rather than showing the whole list in a dropdown.
Here's the sample schema for Variant.
`import { list } from '@keystone-6/core';
import { allowAll } from '@keystone-6/core/access';
import {
text,
relationship,
password,
timestamp,
} from '@keystone-6/core/fields';
import { stars } from '../fields/2-star-field';
export const Variant = list({
access: allowAll,
})`
I've added my complete code here: https://github.com/crup/keystone-poc
Beta Was this translation helpful? Give feedback.
All reactions