Open Rajivkumar1234 opened 5 years ago
It does not provide multi select for field type Select
. but you can create another List
which contains all the values you want to use as select, then use this as Relationship
field with many: true
in option.
see https://keystonejs.netlify.com/api/field/relationship
if you want to have fixed number of items like select, use list option like this and use application update feature which will create the initial items for you, (list options are skipped at this time)
{
noedit: false,
nocreate: false,
nodelete: false,
}
see - https://keystonejs.netlify.com/api/list for more list options.
My Problem Is this , I hope someone from the community can address or answer this one.
I would like to use a combobox at the adminUI with fields that come from a server or a query from a seperate model. I was thinking on get the data with a pre 'find' hook and then override the options atribute at the 'audiences' property in the Schema.
This is the solution I am trying to address and made possible
var audiences = []
```Compliance.add({
title: { type: Types.Text, required: true, initial: true, index: true },
url: { type: Types.Url, required: true, initial: true },
position: { type: Types.Number, initial: true },
audience: { type: Types.Select, options: audiences , many: true, initial: true },
});```
Compliance.schema.pre('save', function (next) {
keystone.list('AnotherModel').model.find()
.exec(function (err, results) {
var modelresults = results
for (i = 0; i < modelresults i++) {
audiences .push(modelresults s[i].name)
}
});
});
Now here comes the second problem the Multi select on types.select
Now they say that Relationship could be able to solve this issue , But
But what if all the data that I wanted to get comes from a single model ?
TestModel.add({
name: { type: String, required: true },
year: { type: String, required: true },
model: { type: String, required: true },
});
var listdata = ["1999", "2020"]
var listdata1 = ["model1", "model2"]
var listdata2 = ["Name 1", "Name"]
TestModel2.add({
name: { type: String, required: true },
value: { type: String },
name: { type: Types.Select, options: listdata2},
year: { type: Types.Select, options: listdata1},
model: { type: Types.Select, options: listdata},
});
How does relationship be able to solve this problem , kindly see screenshot. I just did use arrays on the example above , data should supposed to be from TestModel , I wanted to get all the data from TestModel to TestModel2 which would be 1 select menu for name , year and model and must be able to select multiple data each select menu. How can a Relationship be able to address that ?
Screenshot https://imgur.com/a/mp6KXEp
@gautamsi , @autoboxer . Any Idea that could help ? Thank you. @JedWatson .Thank you.
Are you sure you aren't looking for https://keystonejs.netlify.com/api/field/relationship/ ?
It will create a select with all the values of that other model. Setting it to many: true
will make it a multiselect.
it will not do multiselect
Is this feature has been added to keystone js ?