recordForm now produces selects
This commit is contained in:
parent
5eaf7dbe00
commit
367bf820b5
|
@ -32,6 +32,10 @@ const heading = record => ({
|
||||||
|
|
||||||
const field = (record, f) => {
|
const field = (record, f) => {
|
||||||
if (f.type === "bool") return checkbox(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)
|
return textField(record, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +58,16 @@ const checkbox = (record, f) => ({
|
||||||
checked: fieldValueBinding(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 fieldValueBinding = (record, f) => `state.${record.name}.${f.name}`
|
||||||
|
|
||||||
const capitalize = s => s.charAt(0).toUpperCase() + s.slice(1)
|
const capitalize = s => s.charAt(0).toUpperCase() + s.slice(1)
|
||||||
|
|
Loading…
Reference in New Issue