Skip to content

Commit 583e996

Browse files
committed
[Feat]: #1537 Add Custom Error Message for Invalid Form
1 parent 704a160 commit 583e996

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

client/packages/lowcoder/src/comps/comps/formComp/formComp.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import { messageInstance } from "lowcoder-design/src/components/GlobalInstances"
6060
import { styled } from "styled-components";
6161
import { styleControl } from "@lowcoder-ee/comps/controls/styleControl";
6262
import { AnimationStyle } from "@lowcoder-ee/comps/controls/styleControlConstants";
63+
import { StringControl } from "comps/controls/codeControl";
6364

6465
const FormWrapper = styled.div`
6566
height: 100%;
@@ -80,7 +81,8 @@ const childrenMap = {
8081
disableSubmit: BoolCodeControl,
8182
loading: BoolCodeControl,
8283
onEvent: eventHandlerControl(eventOptions),
83-
animationStyle: styleControl(AnimationStyle)
84+
animationStyle: styleControl(AnimationStyle),
85+
invalidFormMessage: StringControl
8486
};
8587

8688
type FormProps = TriContainerViewProps &
@@ -230,6 +232,7 @@ const FormBaseComp = (function () {
230232
{(useContext(EditorContext).editorModeStatus === "logic" || useContext(EditorContext).editorModeStatus === "both") && (
231233
<Section name={sectionNames.advanced}>
232234
{children.initialData.propertyView({ label: trans("formComp.initialData") })}
235+
{children.invalidFormMessage.propertyView({ label: trans("formComp.invalidFormMessage") })}
233236
</Section>
234237
)}
235238

@@ -363,7 +366,8 @@ let FormTmpComp = class extends FormBaseComp implements IForm {
363366
return Promise.resolve();
364367
});
365368
} else {
366-
messageInstance.error(trans("formComp.notValidForm"));
369+
const customMessage = this.children.invalidFormMessage.getView();
370+
messageInstance.error(customMessage || trans("formComp.notValidForm"));
367371
return Promise.reject("formComp.notValidForm");
368372
}
369373
}

client/packages/lowcoder/src/i18n/locales/en.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2546,6 +2546,7 @@ export const en = {
25462546
"success": "Form Generated Successfully",
25472547
"selectCompType": "Select Component Type",
25482548
"dataSource": "Data Source: ",
2549+
"invalidFormMessage": "Custom Invalid Form Message",
25492550
"selectSource": "Select Source",
25502551
"table": "Table: ",
25512552
"selectTable": "Select Table",

0 commit comments

Comments
 (0)