fix: improve id type semantic and restrict possible types to text and number
This commit is contained in:
committed by
Dan Ribbens
parent
bc2a6e1575
commit
29529b2c56
@@ -1,18 +1,19 @@
|
||||
import { Field } from '../../../../../fields/config/types';
|
||||
import { text } from '../../../../../fields/validations';
|
||||
import validations from '../../../../../fields/validations';
|
||||
|
||||
const formatFields = (collection, isEditing) => {
|
||||
let fields = [
|
||||
...collection.fields,
|
||||
];
|
||||
if (collection.id && !isEditing) {
|
||||
if (collection.idType && !isEditing) {
|
||||
const defaultValidate = validations[collection.idType];
|
||||
fields = [
|
||||
{
|
||||
name: 'id',
|
||||
type: 'text',
|
||||
type: collection.idType,
|
||||
label: 'ID',
|
||||
required: true,
|
||||
validate: (val) => text(val, { required: true }),
|
||||
validate: (val) => defaultValidate(val, { required: true }),
|
||||
} as Field,
|
||||
...fields,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user