#blackhawkjag
1 messages · Page 1 of 1 (latest)
Hi there
Hello!
So you want to dynamically set custom_fields and you are looking to map an array to these custom fields?
Exactly
And you want each different "name" to have a different "label"?
Or you want just one label?
So each label would be the unique item in the array. The value can be the exact same. I.E ["jim", "ted"] would end up {label: "jim", value: '"jim}, {label: "ted", value:"ted"}
Ah okay
So you want to map to an array of objects where you duplicate the value of the array as both the key/value pair for the object
yes
Gotcha then I think what you want to do is just loop through your array and create an array of objects where you add a new object each time to the new array
ok, so when i make that new array of objects outside of the scope. Can i just do custom_fields: [ { key: 'dogs', label: {type: 'custom', custom: 'Which dog are you buying VIP for?'}, optional: false, type: 'dropdown', dropdown: { options: [ {label: 'test1', value: 'test1'} {label: 'test2', value: 'test2'} ] } } ],custom_fields: [ { key: 'dogs', label: {type: 'custom', custom: 'Which dog are you buying VIP for?'}, optional: false, type: 'dropdown', dropdown: { options: [ objectArray ] } } ],?
Sorry ```custom_fields: [
{
key: 'dogs',
label: {type: 'custom', custom: 'Which dog are you buying VIP for?'},
optional: false,
type: 'dropdown',
dropdown: {
options: [
objectArray
]
}
}
],
If your new array of objects is set to contain label and value for the key of each pair then yes that should work
I just tested it and it works flawlessly. Thank you so much, i really appreciate the help!