Skip to content

Commit 42a91f8

Browse files
authored
Merge pull request #109 from lambda-curry/codegen-bot/update-form-error-placement-guidance-1753717445
2 parents 7b19561 + 77c81c2 commit 42a91f8

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

llms.txt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ const LoginForm = () => {
136136
<fetcher.Form onSubmit={methods.handleSubmit} className="max-w-md mx-auto p-6 space-y-4">
137137
<h2 className="text-xl font-semibold text-gray-900">Sign In</h2>
138138

139-
{/* Form-level error display */}
140-
<FormError className="mb-4" />
141-
142139
<TextField
143140
name="email"
144141
type="email"
@@ -155,6 +152,8 @@ const LoginForm = () => {
155152
disabled={isSubmitting}
156153
/>
157154

155+
<FormError className="mb-4" />
156+
158157
<Button type="submit" disabled={isSubmitting} className="w-full">
159158
{isSubmitting ? 'Signing In...' : 'Sign In'}
160159
</Button>
@@ -993,6 +992,9 @@ const ComprehensiveForm = () => {
993992

994993
{/* Submit Button & Status */}
995994
<div className="pt-6">
995+
{/* Form-level errors appear below inputs, above submit button */}
996+
<FormError className="mb-4" />
997+
996998
<Button
997999
type="submit"
9981000
disabled={isSubmitting}
@@ -1007,13 +1009,6 @@ const ComprehensiveForm = () => {
10071009
<p className="text-green-700 font-medium">{fetcher.data.message}</p>
10081010
</div>
10091011
)}
1010-
1011-
{/* General Error */}
1012-
{fetcher.data?.errors?._form && (
1013-
<div className="mt-4 p-4 bg-red-50 border border-red-200 rounded-md">
1014-
<p className="text-red-700 font-medium">{fetcher.data.errors._form.message}</p>
1015-
</div>
1016-
)}
10171012
</div>
10181013
</fetcher.Form>
10191014
</RemixFormProvider>
@@ -1144,14 +1139,14 @@ This comprehensive example serves as a complete reference for implementing any f
11441139

11451140
7. **FormError Placement Options**
11461141
```typescript
1147-
// Top of form (most common)
1142+
// Below inputs, above submit button (most common)
11481143
<FormError className="mb-4" />
11491144

11501145
// Between sections
11511146
<FormError className="my-4 text-center" />
11521147

1153-
// Bottom of form
1154-
<FormError className="mt-4" />
1148+
// Top of form (for critical errors that need immediate attention)
1149+
<FormError className="mb-4" />
11551150

11561151
// Multiple placements with different styling
11571152
<FormError className="mb-4 p-3 bg-red-50 rounded" />
@@ -1212,9 +1207,10 @@ This comprehensive example serves as a complete reference for implementing any f
12121207
- **Be user-friendly**: Avoid technical jargon and error codes
12131208

12141209
### 3. Placement Strategy
1215-
- **Top placement**: For critical errors that should be seen immediately
1210+
- **Below inputs, above submit button**: Most common placement - users see errors after completing form fields but before submitting
1211+
- **Top placement**: For critical errors that need immediate attention before users start filling the form
12161212
- **Inline placement**: For contextual errors related to specific sections
1217-
- **Bottom placement**: For summary or less critical errors
1213+
- **Multiple placements**: FormError can be placed anywhere in the form and styled differently for various use cases
12181214

12191215
### 4. Component Integration
12201216
- FormError works seamlessly with all existing form components

0 commit comments

Comments
 (0)