Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
problem in multi step form with formik in react with nested objects

Hi all I have following code

It is simple form that I founded in internet, after all steps when I submitting the form in console I can see the following data:

   {
     "firstName": "asas",
     "lastName": "wdw",
     "address1": "asasas",
     "city": "1",
     "zipcode": "11111",
     "country": "222",
     "useAddressForPaymentDetails": false,
     "nameOnCard": "AAA",
     "cardNumber": "111123456",
     "expiryDate": "2027-09-26T08:51:30.737Z",
     "cvv": "123",
     } 

But I want to transfer it in nested object as you see in below. I want create payment object for payment step


   {
     "firstName": "asas",
     "lastName": "wdw",
     "address1": "asasas",
     "city": "1",
     "zipcode": "11111",
     "country": "222",
     "useAddressForPaymentDetails": false,
      payment:{
        "nameOnCard": "AAA",
        "cardNumber": "111123456",
        "expiryDate": "2027-09-26T08:51:30.737Z",
        "cvv": "123",
       },
     } 

I already change somethings in project to get that result:

initialValues:

   const {
      formField: {
        firstName,
        lastName,
        address1,
        city,
        zipcode,
        country,
        useAddressForPaymentDetails,
        payment,
      }
    } = checkoutFormModel;

    export default {
       [firstName.name]: "",
       [lastName.name]: "",
       [address1.name]: "",

      [payment.nameOnCard.name]: "",
      [payment.cardNumber.name]: "",
      [payment.expiryDate.name]: "",
      [payment.cvv.name]: ""
};

checkoutModel:

   export default {
     formId: "checkoutForm",
     formField: {
       payment: {
         nameOnCard: {
         name: "nameOnCard",
         label: "Name on card*",
       },
        cardNumber: {
        name: "cardNumber",
        label: "Card number*",
       }
    ...
   }

But it's not working .... Please help me to fixed that in code...sorry I can only give link to that code.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!