Skip to content

Commit b4388e7

Browse files
docs(nextjs-ssr): clarify need for HTML name attribute in form submissions (#1574)
* docs(nextjs-ssr): clarify need for HTML name attribute in native form submissions add inline comments to client components in next.js server action examples highlighting the need to explicitly set the name attribute on input fields for native POST submissions (e.g. with Next.js Server Actions). This avoids confusion where inputs may otherwise be omitted from formData. closes #1565 * docs: change hardcoded name to field name --------- Co-authored-by: LeCarbonator <18158911+LeCarbonator@users.noreply.github.com>
1 parent 582bd41 commit b4388e7

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/framework/react/guides/ssr.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function Home() {
147147
return (
148148
<div>
149149
<input
150-
name="age"
150+
name={field.name}
151151
type="number"
152152
value={field.state.value}
153153
onChange={(e) => field.handleChange(e.target.valueAsNumber)}
@@ -293,7 +293,7 @@ export const ClientComp = () => {
293293
return (
294294
<div>
295295
<input
296-
name="age"
296+
name={field.name} // must explicitly set the name attribute for the POST request
297297
type="number"
298298
value={field.state.value}
299299
onChange={(e) => field.handleChange(e.target.valueAsNumber)}

examples/react/next-server-actions/src/app/client-component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const ClientComp = () => {
3737
return (
3838
<div>
3939
<input
40-
name="age"
40+
name={field.name} // must explicitly set the name attribute for the POST request
4141
type="number"
4242
value={field.state.value}
4343
onChange={(e) => field.handleChange(e.target.valueAsNumber)}

0 commit comments

Comments
 (0)