Code Monkey home page Code Monkey logo

youtube-2020-june-multi-step-form-formik's Introduction

This is a Next.js project bootstrapped with create-next-app.

Getting Started

Deployed Demo: http://youtube-2020-june-multi-step-form-formik.bmvantunes.vercel.app/

First, run the development server:

npm run dev
# or
yarn dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying pages/index.js. The page auto-updates as you edit the file.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

youtube-2020-june-multi-step-form-formik's People

Contributors

bmvantunes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

youtube-2020-june-multi-step-form-formik's Issues

How do I implement nested steps within an individual Material UI Stepper Step (A Step Within A Stepper Step [Child Steps within Parent Steps] )

I want to use nested Step Components within a Material UI Stepper Component

This is the behavior that the client expects. I am using Material UI, and Formik within a NextJS context. I am using the tutorial as a reference.
image

Wireframes

Below are some wireframes that help illustrate what each the three top-level parent steps, and the third screenshot illustrates that the last parent step (step 3) has three, nested child steps.

Parent Step One - Tell Us About Your Property NO CHILDREN STEPS

This is the first step in the form. The customer will provide info on the land or standing structure that will have media produced (depending on there choice certain products will not be options they can select).

Screenshot 1: This is the first step in the form

image

Parent Step Two - Select Your Services A PORTAL WITH MULTIPLE PRODUCTS AND PACKAGES

This step will actually be a non-linear portal to seeing categorized products. There are four service categories with products and sub-packages. The goal is to be able to pick and select products and add them to the cart.

Screenshot 2: This is the homepage/ portal

image

Parent Step Three - Provide Some Info 3 CHILD STEPS

This step will actually be a non-linear portal to seeing categorized products. There are four service categories with products and sub-packages. The goal is to be able to pick and select products and add them to the cart.

Screenshot 3: This is the place we collect info within 3 child "steps"

image

Here is the rundown on the Material Ui Stepper Component.
https://material-ui.com/components/steppers/

Here is a stack question I posted:
https://stackoverflow.com/questions/64883191/how-do-i-implement-nested-steps-within-an-individual-material-ui-stepper-step-a

Passing formik props to children

Absolutely brilliant demo and video.

I've been trying to use react-bootstrap instead of formiks fields, but what I want to do is pass additional formik props in the children so I can use formiks (values, errors and touched) implementation.

Do you perhaps know how I could pass down formik props to the FormikStep so that any react bootstrap field I implement can access formiks touched, values and errors for example?

https://react-bootstrap.github.io/components/forms/#forms-validation-libraries <-- example here of the extra formik items mentioned above.

Thanks

How to use FormikStep inside a component within a FormikStepper

Hi,

Thanks for the wonderful video and for providing all the code.

I am creating a site and would like to make FormikSteps within component so I can reuse them and make sure I keep the code DRY.

The problem I am having is when calling the component which returns a FormikStep inside a FormikStepper, the label and validationSchema don't exist on the parent, therefore the FormikStepper cannot access them.

Please see some example code:

MyForm.js

export default function MyForm() {
  const classes = useStyles();

  return (
      <Box p={2}>
        <FormikStepper
          initialValues={{ name: "" }}
          onSubmit={(values, actions) => {
            actions.setSubmitting(false);
            console.log(values);
          }}
        >

          <ReusableStep />

        </FormikStepper>
      </Box>
  );
}

ReusableStep.js

export default function ReusableStep() {

  return (
    <FormikStep
      label="Reusable Form Step"
      validationSchema={Yup.object({})}
    >

              <Grid item xs={12} sm={true}>

                <Field
                  component={TextField}
                  type="text"
                  name="name"
                  label="Name"
                  fullWidth
                />

              </Grid>
    <FormikStep />
  )
}

When in the current state, the validation doesn't work, and the Material UI Step doesn't get a label.

The only way I can get it to work is by passing validationSchema and label to the ReusableStep:

<ReusableStep 
      label="Reusable Form Step"
      validationSchema={Yup.object({})}
/>

This is not great, as I would have to repeat defining the schema each time I want to use the FormikStep.

Please could you help me get this sorted?

Many thanks,
Zac

How to define a field value?

I can't set a field value after an onBlur.

something like:

const handleCEP = (ev, props) => {
  props.handleChange(ev);
  
  fetch(`https://viacep.com.br/ws/77807060/json/`)
    .then((res) => res.json())
    .then((data) => {
      props.setFieldValue("logradouro", data.logradouro);
    });
};
<Field
  name="cep"
  component={TextField}
  type="text"
  label="CEP"
  placeholder="Qual seu CEP?"
  variant="outlined"
  onBlur={(ev) => handleCEP(ev, props)}
  fullWidth
/>

Can you help me? Thank you!

how to use setFieldValue() inside FormikStep component

in my case i need to change a lot after check a box so ๐Ÿ‘๐Ÿป

 <Field
      name={`categories[${j}].choice`}
      type="checkbox"
      value={choice["@id"]}
      component={CheckboxWithLabel}
      Label={{ label: choice.label }}
      onChange={val => {
           setFieldValue(`categories[${j}].choice`, val);
           setFieldValue(`categories[${j}].question`, question["@id"]);
           setFieldValue(`categories[${j}].user`, `/api/users/${user.id}`);
           setFieldValue(`categories[${j}].compaign`, `/api/compaigns/${user.id}`);
       }}
  />

how to use it and thnx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.