From 0b3c62d426a09b67315b5a2f8c7e189f755ddd0a Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Thu, 27 Feb 2020 22:06:53 +0000 Subject: [PATCH] recordForm now produces selects --- .../src/Templates/recordForm.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/materialdesign-components/src/Templates/recordForm.js b/packages/materialdesign-components/src/Templates/recordForm.js index c41c52b147..64fc6af8b7 100644 --- a/packages/materialdesign-components/src/Templates/recordForm.js +++ b/packages/materialdesign-components/src/Templates/recordForm.js @@ -32,6 +32,10 @@ const heading = record => ({ const field = (record, f) => { if (f.type === "bool") return checkbox(record, f) + if (f.type === "string" + && f.typeOptions + && f.typeOptions.values + && f.typeOptions.values.length > 0) return select(record, f) return textField(record, f) } @@ -54,6 +58,16 @@ const checkbox = (record, f) => ({ checked: fieldValueBinding(record, f), }) +const select = (record, f) => ({ + _component: "@budibase/standard-components/select", + value: fieldValueBinding(record, f), + _children: f.typeOptions.values.map(val => ({ + _component: "@budibase/standard-components/option", + value: val, + text: val + })) +}) + const fieldValueBinding = (record, f) => `state.${record.name}.${f.name}` const capitalize = s => s.charAt(0).toUpperCase() + s.slice(1)