`
function isNil(obj) {
return obj == null;
}
export function buildFormItem(decorator, item, key) {
const {
id,
label,
extra,
layout,
props,
value,
rules,
options,
input,
required,
additional,
} = item;
// FormItem props
const mergedProps = { …props, …layout };
if (label) {
mergedProps.label = label;
}
if (extra) {
mergedProps.extra = extra;
}
if (!isNil(key)) {
mergedProps.key = key;
}
if (required) {
mergedProps.required = true;
}
const mergedOptions = isNil(value)
? { …options, rules }
: { …options, rules, initialValue: value };
return (
<Form.Item {…mergedProps}>
{decorator(id, mergedOptions)(input)}
{additional || null}
</Form.Item>
);
}
export default function buildFormItems(decorator, items) {
return items.map((item, index) => buildFormItem(decorator, item, item.id || index));
}`
9692

被折叠的 条评论
为什么被折叠?



