Skip to content
Discussion options

You must be logged in to vote

Simple cases

In simple cases, you can build a form with multiple inputs with same name attributes, and then browser/Remix will serialize and allow us to read it as array from formData.getAll("fieldName"). (They are the web standards, #useThePlatform!)

Then what you probably want to do is transposing the fields array into array of object with fields. Here's a example of a complete route which does that:

import {Form, useActionData} from "@remix-run/react";
import {ActionFunction} from "remix";

export const action: ActionFunction = async ({request}) => {
    const formData = await request.formData();
    // 2. Here comes 2 arrays. Transpose them to be array of objects
    const firstNames = 

Replies: 7 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@hotstone
Comment options

Comment options

You must be logged in to vote
4 replies
@maprangsoft
Comment options

@cardfaux
Comment options

@cstrat
Comment options

@whiskerside
Comment options

Answer selected by machour
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@davidhousedev
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet