Skip to content
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

Add docs for new props on fe config, inputComponent, getDefaultValue, nonOptionalErrorMsg #744

Merged
merged 61 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
4c1835c
Setup docs for input component prop
amitbadala Nov 8, 2023
e1fc523
Add docs for getDefaultValue prop
amitbadala Nov 8, 2023
de0b401
Ensure consistent naming
amitbadala Nov 9, 2023
830bb82
Add important note
amitbadala Nov 9, 2023
17f939c
Add documentation for nonOptionalError flag
amitbadala Nov 9, 2023
61a4a70
Better img description
amitbadala Nov 9, 2023
2487840
Better message
amitbadala Nov 9, 2023
74a6b72
Add docs for signin default values
amitbadala Nov 9, 2023
d603821
Better img name
amitbadala Nov 9, 2023
8b30001
Add docs for signin non optional error message
amitbadala Nov 9, 2023
3ff43ad
Minor typo
amitbadala Nov 9, 2023
1144db7
Merge everything in single page - Changing Field Props
amitbadala Nov 14, 2023
7b9ca8e
Merge field props for emailpassword signin
amitbadala Nov 14, 2023
8ef45bc
Merge for signin, better names for sections
amitbadala Nov 14, 2023
25dc231
Propogating new features from EmailPassword to thirdparty with COPY DOCS
amitbadala Nov 14, 2023
0123161
Make docs more dynamic to be used across multiple recipie
amitbadala Nov 14, 2023
8f8c0ce
Updating links everywhere, delete unwanted files
amitbadala Nov 14, 2023
bb05666
Instead of deleting file, redirect
amitbadala Nov 15, 2023
6f19208
Typo Fixes, better copy
amitbadala Nov 15, 2023
c2616f9
Update name from additional-field-props to customising-each-form-field
amitbadala Nov 17, 2023
3de5e07
Update links
amitbadala Nov 17, 2023
17d8cae
Better styling for custom components supported with imgs for thirdpar…
amitbadala Nov 17, 2023
e1931f6
Update screenshot for emailpassword recipie
amitbadala Nov 17, 2023
2a0b19e
Add screenshot for thirdparty custom error
amitbadala Nov 17, 2023
5e33e76
Update screenshots for default paylod and also import images dynamica…
amitbadala Nov 17, 2023
713d05e
Update signin image screenshots for thirpartyemailpassword
amitbadala Nov 17, 2023
0bba043
Add docs for changing field order in email password and thirdparty
amitbadala Nov 20, 2023
d87b310
For changing field order add react-router-dom example as well
amitbadala Nov 20, 2023
682aacb
Fix imports & highlight code
amitbadala Nov 20, 2023
935dc23
Add custom ui tabs to signin ep
amitbadala Nov 21, 2023
14bbedb
Use latest tabs for sign-in
amitbadala Nov 22, 2023
cdc11a1
Use latest tabs for sign-up
amitbadala Nov 22, 2023
30e3bb1
Fix tab issue
amitbadala Nov 22, 2023
bb2f8b0
Update screenshots for custom components
amitbadala Nov 22, 2023
963ac92
Remove unwanted files
amitbadala Nov 22, 2023
4693b63
Add css for custoim components
amitbadala Nov 22, 2023
3518616
Minor typo fix
amitbadala Nov 22, 2023
081cc82
Update screenshots for emailpassword signups
amitbadala Nov 22, 2023
10c460d
Fix broken images
amitbadala Nov 22, 2023
9604a41
Copy update
amitbadala Nov 22, 2023
2b144c4
Add switcher to third party email password
amitbadala Nov 22, 2023
6d25193
Cleanup signin
amitbadala Nov 22, 2023
531ede9
Remove repetitive content for signin custom ui
amitbadala Nov 23, 2023
574c6da
Cleanup custom ui content for signup form
amitbadala Nov 23, 2023
615dbb6
Update old screenshot to be consistent
amitbadala Nov 23, 2023
3082666
Hide toc from custom ui for customisation field
amitbadala Nov 23, 2023
eed9f71
Update adding-fields for ep, add UI switcher and update FE tabs
amitbadala Nov 23, 2023
61c3dcf
Update adding-fields for tpep
amitbadala Nov 23, 2023
2810a64
Update field validators for tpep signup
amitbadala Nov 23, 2023
14c3028
Update field validators for email-password recipie
amitbadala Nov 23, 2023
e3dfbf4
Update field validators to show the backend in custom-ui
amitbadala Nov 24, 2023
8d2aa91
Fix indentation to ensure, sidebar is visible correctly
amitbadala Nov 24, 2023
13b0126
Update custom ui component for adding-fields for third party password
amitbadala Nov 24, 2023
dffc13f
Update custom ui component for adding-fields for email password recipie
amitbadala Nov 24, 2023
a59447a
Use copy section between ep & tpep
amitbadala Nov 24, 2023
15aa569
Implement feedbacks
amitbadala Nov 24, 2023
2df21c8
Update screenshot for thirpartyemailpassword add-fields custom-ui
amitbadala Nov 24, 2023
f042474
Add a note for handling responses
amitbadala Nov 24, 2023
cb651b3
Update links
amitbadala Nov 24, 2023
f3e6cd2
Make the note available across the tabs
amitbadala Nov 24, 2023
9565327
Merge pull request #751 from supertokens/update-tabs-for-formfields
rishabhpoddar Nov 24, 2023
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 @@ -4,46 +4,6 @@ title: Changing Field Labels and Placeholder text
hide_title: true
---

import FrontendSDKTabs from "/src/components/tabs/FrontendSDKTabs"
import TabItem from '@theme/TabItem';
import Redirector from '/src/components/Redirector'

# Changing Field Labels and Placeholder text

If you would like to modify the fields in the login widget, by changing UI labels or placeholder text, you can do so by modifying the `formFields` property when initializing SuperTokens on the frontend.

<FrontendSDKTabs>
<TabItem value="reactjs">

```tsx
import SuperTokens from "supertokens-auth-react";
import EmailPassword from "supertokens-auth-react/recipe/emailpassword";
import Session from "supertokens-auth-react/recipe/session";

SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
EmailPassword.init({
signInAndUpFeature: {
signInForm: {
// highlight-start
formFields: [{
id: "email",
label: "customFieldName",
placeholder: "Custom value"
}]
}
// highlight-end
}
}),
Session.init()
]
});
```
</TabItem>
</FrontendSDKTabs>

<img alt="Prebuilt form UI with custom labels and placeholder" src="/img/emailpassword/modified-formfields.png" />
<Redirector to={"./customising-each-form-field"}/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
---
id: customising-each-form-field
title: Customising each form field
hide_title: true
show_ui_switcher: true
---

<!-- COPY DOCS -->
<!-- ./emailpassword/common-customizations/signin-form/customising-each-form-field.mdx -->

import TabItem from '@theme/TabItem'
import {PreBuiltOrCustomUISwitcher, PreBuiltUIContent, CustomUIContent} from "/src/components/preBuiltOrCustomUISwitcher"
import FrontendPreBuiltUITabs from "/src/components/tabs/FrontendPreBuiltUITabs";


# Customising each form field

* [Modify Labels and Placeholder Text](#modify-labels-and-placeholder-text)
* [Setting Default Values](#setting-default-values)
* [Changing Optional Error Message](#changing-optional-error-message)
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved


<PreBuiltOrCustomUISwitcher>

<CustomUIContent>

:::caution Not applicable
This section is not relevant for custom UI, as you will be creating your own UI and already have control over the form fields.
:::

</CustomUIContent>

<PreBuiltUIContent>

## Modify Labels and Placeholder Text

If you would like to modify the fields in the login widget, by changing UI labels or placeholder text, you can do so by modifying the `formFields` property when initializing SuperTokens on the frontend.

<FrontendPreBuiltUITabs>
<TabItem value="reactjs">

```tsx
import SuperTokens from "supertokens-auth-react";
import ^{recipeNameCapitalLetters} from "supertokens-auth-react/recipe/^{codeImportRecipeName}";
import Session from "supertokens-auth-react/recipe/session";

SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
^{recipeNameCapitalLetters}.init({
signInAndUpFeature: {
signInForm: {
// highlight-start
formFields: [{
id: "email",
label: "customFieldName",
placeholder: "Custom value"
}]
}
// highlight-end
}
}),
Session.init()
]
});
```
</TabItem>
</FrontendPreBuiltUITabs>

<img alt="Prebuilt form UI with custom labels and placeholder" src="/img/^{codeImportRecipeName}/modified-formfields.png" />

</PreBuiltUIContent>
</PreBuiltOrCustomUISwitcher>


<PreBuiltOrCustomUISwitcher>
<PreBuiltUIContent>

## Setting Default Values

To fill in the form fields with preset values in the login widget, add a `getDefaultValue` option to the `formFields` config when initializing SuperTokens on the frontend.

<FrontendPreBuiltUITabs>
<TabItem value="reactjs">

```tsx
import SuperTokens from "supertokens-auth-react";
import ^{recipeNameCapitalLetters} from "supertokens-auth-react/recipe/^{codeImportRecipeName}";
import Session from "supertokens-auth-react/recipe/session";

SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
^{recipeNameCapitalLetters}.init({
signInAndUpFeature: {
signInForm: {
formFields: [{
id: "email",
label: "Your Email",
// highlight-start
getDefaultValue: () => "[email protected]"
// highlight-end
}]
}
}
}),
Session.init()
]
});
```
</TabItem>
</FrontendPreBuiltUITabs>

<img alt="Prebuilt signin form UI with default values for fields" src="/img/^{codeImportRecipeName}/signin-with-default-values.png" />


:::important

The return value of `getDefaultValue` function must be a string

:::

</PreBuiltUIContent>
</PreBuiltOrCustomUISwitcher>


<PreBuiltOrCustomUISwitcher>
<PreBuiltUIContent>

## Changing Optional Error Message


When you try to submit login form without filling in required / non-optional fields, the SDK will, by default, show an error stating that the `Field is not optional`. You can customize this error message with `nonOptionalErrorMsg` property in the formField config.

Let's see how to achieve it.

<FrontendPreBuiltUITabs>
<TabItem value="reactjs">

```tsx
import SuperTokens from "supertokens-auth-react";
import ^{recipeNameCapitalLetters} from "supertokens-auth-react/recipe/^{codeImportRecipeName}";
import Session from "supertokens-auth-react/recipe/session";

SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
^{recipeNameCapitalLetters}.init({
signInAndUpFeature: {
signInForm: {
formFields: [{
id: "email",
label: "Your Email",
placeholder: "Email",
// highlight-start
nonOptionalErrorMsg: "Please add your email"
// highlight-end
}]
}
}
}),
Session.init()
]
});
```
</TabItem>
</FrontendPreBuiltUITabs>

<img alt="Prebuilt form UI with custom error message" src="/img/^{codeImportRecipeName}/signin-with-custom-error-msg.png" />


Observe how the `password` field displays the standard error message because a custom message wasn't assigned using `nonOptionalErrorMsg` for that field.

:::tip

To display an error message for required/non-optional fields, make use of the `nonOptionalErrorMsg` property.
For complex validations of fields, make use of [field validators](/docs/^{docsLinkRecipeName}/common-customizations/signin-form/field-validators).

:::

</PreBuiltUIContent>
</PreBuiltOrCustomUISwitcher>
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,6 @@ title: Changing Field Labels and Placeholder text
hide_title: true
---

import FrontendSDKTabs from "/src/components/tabs/FrontendSDKTabs"
import TabItem from '@theme/TabItem';
import Redirector from '/src/components/Redirector'

# Changing Field Labels and Placeholder text

If you would like to modify the fields in the login widget, by changing UI labels or placeholder text, you can do so by modifying the `formFields` property when initializing SuperTokens on the frontend.

<FrontendSDKTabs>
<TabItem value="reactjs">

```tsx
import SuperTokens from "supertokens-auth-react";
import EmailPassword from "supertokens-auth-react/recipe/emailpassword";
import Session from "supertokens-auth-react/recipe/session";

SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
EmailPassword.init({
signInAndUpFeature: {
signUpForm: {
// highlight-start
formFields: [{
id: "email",
label: "customFieldName",
placeholder: "Custom value"
}]
}
// highlight-end
}
}),
Session.init()
]
});
```
</TabItem>
</FrontendSDKTabs>

<img alt="Prebuilt form UI with custom labels and placeholder" src="/img/emailpassword/custom-field-name-signup-ep.png" />
<Redirector to={"./customising-each-form-field"}/>
Loading