make "text" the default value (#7543)
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
This commit is contained in:
co-authored by
CarinaWolli
parent
b247075a19
commit
a0f55707e2
@@ -255,7 +255,7 @@ export const FormBuilder = function FormBuilder({
|
||||
remove(index);
|
||||
};
|
||||
|
||||
const fieldType = FieldTypesMap[fieldForm.watch("type")];
|
||||
const fieldType = FieldTypesMap[fieldForm.watch("type") || "text"];
|
||||
const isFieldEditMode = fieldDialog.fieldIndex !== -1;
|
||||
return (
|
||||
<div>
|
||||
@@ -374,6 +374,7 @@ export const FormBuilder = function FormBuilder({
|
||||
<Form
|
||||
form={fieldForm}
|
||||
handleSubmit={(data) => {
|
||||
const type = data.type || "text";
|
||||
const isNewField = fieldDialog.fieldIndex == -1;
|
||||
if (isNewField && fields.some((f) => f.name === data.name)) {
|
||||
showToast(t("form_builder_field_already_exists"), "error");
|
||||
@@ -384,6 +385,7 @@ export const FormBuilder = function FormBuilder({
|
||||
} else {
|
||||
const field: RhfFormField = {
|
||||
...data,
|
||||
type,
|
||||
sources: [
|
||||
{
|
||||
label: "User",
|
||||
@@ -402,7 +404,7 @@ export const FormBuilder = function FormBuilder({
|
||||
});
|
||||
}}>
|
||||
<SelectField
|
||||
required
|
||||
defaultValue={FieldTypes[3]} // "text" as defaultValue
|
||||
isDisabled={
|
||||
fieldForm.getValues("editable") === "system" ||
|
||||
fieldForm.getValues("editable") === "system-but-optional"
|
||||
@@ -543,7 +545,7 @@ export const ComponentForField = ({
|
||||
};
|
||||
readOnly: boolean;
|
||||
} & ValueProps) => {
|
||||
const fieldType = field.type;
|
||||
const fieldType = field.type || "text";
|
||||
const componentConfig = Components[fieldType];
|
||||
|
||||
const isValueOfPropsType = (val: unknown, propsType: typeof componentConfig.propsType) => {
|
||||
|
||||
Reference in New Issue
Block a user