Skip to content

[Feat]: #1537 Add Custom Invalid Form Message #1672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import { messageInstance } from "lowcoder-design/src/components/GlobalInstances"
import { styled } from "styled-components";
import { styleControl } from "@lowcoder-ee/comps/controls/styleControl";
import { AnimationStyle } from "@lowcoder-ee/comps/controls/styleControlConstants";
import { StringControl } from "comps/controls/codeControl";

const FormWrapper = styled.div`
height: 100%;
Expand All @@ -80,7 +81,8 @@ const childrenMap = {
disableSubmit: BoolCodeControl,
loading: BoolCodeControl,
onEvent: eventHandlerControl(eventOptions),
animationStyle: styleControl(AnimationStyle)
animationStyle: styleControl(AnimationStyle),
invalidFormMessage: StringControl
};

type FormProps = TriContainerViewProps &
Expand Down Expand Up @@ -230,6 +232,7 @@ const FormBaseComp = (function () {
{(useContext(EditorContext).editorModeStatus === "logic" || useContext(EditorContext).editorModeStatus === "both") && (
<Section name={sectionNames.advanced}>
{children.initialData.propertyView({ label: trans("formComp.initialData") })}
{children.invalidFormMessage.propertyView({ label: trans("formComp.invalidFormMessage") })}
</Section>
)}

Expand Down Expand Up @@ -363,7 +366,8 @@ let FormTmpComp = class extends FormBaseComp implements IForm {
return Promise.resolve();
});
} else {
messageInstance.error(trans("formComp.notValidForm"));
const customMessage = this.children.invalidFormMessage.getView();
messageInstance.error(customMessage || trans("formComp.notValidForm"));
return Promise.reject("formComp.notValidForm");
}
}
Expand Down
1 change: 1 addition & 0 deletions client/packages/lowcoder/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2546,6 +2546,7 @@ export const en = {
"success": "Form Generated Successfully",
"selectCompType": "Select Component Type",
"dataSource": "Data Source: ",
"invalidFormMessage": "Custom Invalid Form Message",
"selectSource": "Select Source",
"table": "Table: ",
"selectTable": "Select Table",
Expand Down
Loading