Skip to content

Commit

Permalink
feat: Add default values for LoginForm configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
m453h committed Dec 5, 2024
1 parent 13feded commit cf6deea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
function formInputFieldGroup({
label,
name,
includeErrorMessageField = true,
includeHintField = false,
includeErrorMessageField = true,
defaultLabelValue = "",
defaultErrorMessage = "",
defaultHint = "",
additionalFields = [],
}) {
const fields = [
{
name: `${name}Label`,
label: "Label",
type: "text",
defaultValue: defaultLabelValue,
required: true,
},
];
Expand All @@ -19,6 +23,7 @@ function formInputFieldGroup({
name: `${name}Hint`,
label: "Hint",
type: "text",
defaultValue: defaultHint,
required: true,
});
}
Expand All @@ -28,6 +33,7 @@ function formInputFieldGroup({
name: `${name}ErrorMessage`,
type: "text",
label: "Error Message",
defaultValue: defaultErrorMessage,
required: true,
});
}
Expand Down
14 changes: 12 additions & 2 deletions apps/civicsignalblog/src/payload/globals/Forms/login/LoginTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,18 @@ const LoginTab = {
type: "collapsible",
label: "Fields",
fields: [
formInputFieldGroup({ label: "E-mail", name: "email" }),
formInputFieldGroup({ label: "Password", name: "password" }),
formInputFieldGroup({
label: "E-mail",
name: "email",
defaultLabelValue: "Email",
defaultErrorMessage: "You need to enter your email address.",
}),
formInputFieldGroup({
label: "Password",
name: "password",
defaultLabelValue: "Password",
defaultErrorMessage: "You need to enter your password.",
}),
],
},
{
Expand Down

0 comments on commit cf6deea

Please sign in to comment.