feat: add date and multiselect custom fields

This commit is contained in:
Barış Soner Uşaklı
2024-11-20 11:01:01 -05:00
parent e375038ce0
commit 9cf85cede3
8 changed files with 44 additions and 8 deletions

View File

@@ -144,14 +144,23 @@ helpers.getCustomUserFields = async function (userData) {
});
fields.forEach((f) => {
let userValue = userData[f.key];
if (f.type === 'select-multi' && userValue) {
userValue = JSON.parse(userValue || '[]');
}
f['select-options'] = f['select-options'].split('\n').filter(Boolean).map(
opt => ({
value: opt,
selected: opt === userData[f.key],
selected: Array.isArray(userValue) ?
userValue.includes(opt) :
opt === userValue,
})
);
if (userData[f.key]) {
f.value = validator.escape(String(userData[f.key]));
if (userValue) {
if (Array.isArray(userValue)) {
userValue = userValue.join(', ');
}
f.value = validator.escape(String(userValue));
}
});
return fields;