How to add Material-UI form with Steppers in React-Amin Create Component












0















I have a very long form in my React-Admin app.
I would like to add the form elements to a stepper.



From Material-UI, they provide an example of Steppers



What id like to be assisted on is




  1. How to add components such as to the stepper's function



getStepContent()





  1. How to wrap all input components into a form



  2. Avoid moving to the next step if form in ine step is not validated.



    function getStepContent(stepIndex) {
    switch (stepIndex) {
    case 0:
    return 'Select campaign settings...';
    case 1:
    return 'What is an ad group anyways?';
    case 2:
    return 'This is the bit I really care about!';
    default:
    return 'Uknown stepIndex';
    }
    }



    class HorizontalLabelPositionBelowStepper extends React.Component {
    state = {
    activeStep: 0,
    };



    handleNext = () => {
    this.setState(state => ({
    activeStep: state.activeStep + 1,
    }));
    };



    handleBack = () => {
    this.setState(state => ({
    activeStep: state.activeStep - 1,
    }));
    };



    handleReset = () => {
    this.setState({
    activeStep: 0,
    });
    };



    render() {
    const { classes } = this.props;
    const steps = getSteps();
    const { activeStep } = this.state;



    return (
    <div className={classes.root}>
    <Stepper activeStep={activeStep} alternativeLabel>
    {steps.map(label => {
    return (
    <Step key={label}>
    <StepLabel>{label}</StepLabel>
    </Step>
    );
    })}
    </Stepper>
    <div>
    {this.state.activeStep === steps.length ? (
    <div>
    <Typography className={classes.instructions}>All steps completed</Typography>
    <Button onClick={this.handleReset}>Reset</Button>
    </div>
    ) : (
    <div>
    <Typography className={classes.instructions}>{getStepContent(activeStep)}</Typography>
    <div>
    <Button
    disabled={activeStep === 0}
    onClick={this.handleBack}
    className={classes.backButton}
    >
    Back
    </Button>
    <Button variant="contained" color="primary" onClick={this.handleNext}>
    {activeStep === steps.length - 1 ? 'Finish' : Next'}
    </Button>
    </div>
    </div>
    )}
    </div>
    </div>
    );


    }
    }



    HorizontalLabelPositionBelowStepper.propTypes = {
    classes: PropTypes.object,
    };



    export default withStyles(styles(HorizontalLabelPositionBelowStepper);












share|improve this question



























    0















    I have a very long form in my React-Admin app.
    I would like to add the form elements to a stepper.



    From Material-UI, they provide an example of Steppers



    What id like to be assisted on is




    1. How to add components such as to the stepper's function



    getStepContent()





    1. How to wrap all input components into a form



    2. Avoid moving to the next step if form in ine step is not validated.



      function getStepContent(stepIndex) {
      switch (stepIndex) {
      case 0:
      return 'Select campaign settings...';
      case 1:
      return 'What is an ad group anyways?';
      case 2:
      return 'This is the bit I really care about!';
      default:
      return 'Uknown stepIndex';
      }
      }



      class HorizontalLabelPositionBelowStepper extends React.Component {
      state = {
      activeStep: 0,
      };



      handleNext = () => {
      this.setState(state => ({
      activeStep: state.activeStep + 1,
      }));
      };



      handleBack = () => {
      this.setState(state => ({
      activeStep: state.activeStep - 1,
      }));
      };



      handleReset = () => {
      this.setState({
      activeStep: 0,
      });
      };



      render() {
      const { classes } = this.props;
      const steps = getSteps();
      const { activeStep } = this.state;



      return (
      <div className={classes.root}>
      <Stepper activeStep={activeStep} alternativeLabel>
      {steps.map(label => {
      return (
      <Step key={label}>
      <StepLabel>{label}</StepLabel>
      </Step>
      );
      })}
      </Stepper>
      <div>
      {this.state.activeStep === steps.length ? (
      <div>
      <Typography className={classes.instructions}>All steps completed</Typography>
      <Button onClick={this.handleReset}>Reset</Button>
      </div>
      ) : (
      <div>
      <Typography className={classes.instructions}>{getStepContent(activeStep)}</Typography>
      <div>
      <Button
      disabled={activeStep === 0}
      onClick={this.handleBack}
      className={classes.backButton}
      >
      Back
      </Button>
      <Button variant="contained" color="primary" onClick={this.handleNext}>
      {activeStep === steps.length - 1 ? 'Finish' : Next'}
      </Button>
      </div>
      </div>
      )}
      </div>
      </div>
      );


      }
      }



      HorizontalLabelPositionBelowStepper.propTypes = {
      classes: PropTypes.object,
      };



      export default withStyles(styles(HorizontalLabelPositionBelowStepper);












    share|improve this question

























      0












      0








      0








      I have a very long form in my React-Admin app.
      I would like to add the form elements to a stepper.



      From Material-UI, they provide an example of Steppers



      What id like to be assisted on is




      1. How to add components such as to the stepper's function



      getStepContent()





      1. How to wrap all input components into a form



      2. Avoid moving to the next step if form in ine step is not validated.



        function getStepContent(stepIndex) {
        switch (stepIndex) {
        case 0:
        return 'Select campaign settings...';
        case 1:
        return 'What is an ad group anyways?';
        case 2:
        return 'This is the bit I really care about!';
        default:
        return 'Uknown stepIndex';
        }
        }



        class HorizontalLabelPositionBelowStepper extends React.Component {
        state = {
        activeStep: 0,
        };



        handleNext = () => {
        this.setState(state => ({
        activeStep: state.activeStep + 1,
        }));
        };



        handleBack = () => {
        this.setState(state => ({
        activeStep: state.activeStep - 1,
        }));
        };



        handleReset = () => {
        this.setState({
        activeStep: 0,
        });
        };



        render() {
        const { classes } = this.props;
        const steps = getSteps();
        const { activeStep } = this.state;



        return (
        <div className={classes.root}>
        <Stepper activeStep={activeStep} alternativeLabel>
        {steps.map(label => {
        return (
        <Step key={label}>
        <StepLabel>{label}</StepLabel>
        </Step>
        );
        })}
        </Stepper>
        <div>
        {this.state.activeStep === steps.length ? (
        <div>
        <Typography className={classes.instructions}>All steps completed</Typography>
        <Button onClick={this.handleReset}>Reset</Button>
        </div>
        ) : (
        <div>
        <Typography className={classes.instructions}>{getStepContent(activeStep)}</Typography>
        <div>
        <Button
        disabled={activeStep === 0}
        onClick={this.handleBack}
        className={classes.backButton}
        >
        Back
        </Button>
        <Button variant="contained" color="primary" onClick={this.handleNext}>
        {activeStep === steps.length - 1 ? 'Finish' : Next'}
        </Button>
        </div>
        </div>
        )}
        </div>
        </div>
        );


        }
        }



        HorizontalLabelPositionBelowStepper.propTypes = {
        classes: PropTypes.object,
        };



        export default withStyles(styles(HorizontalLabelPositionBelowStepper);












      share|improve this question














      I have a very long form in my React-Admin app.
      I would like to add the form elements to a stepper.



      From Material-UI, they provide an example of Steppers



      What id like to be assisted on is




      1. How to add components such as to the stepper's function



      getStepContent()





      1. How to wrap all input components into a form



      2. Avoid moving to the next step if form in ine step is not validated.



        function getStepContent(stepIndex) {
        switch (stepIndex) {
        case 0:
        return 'Select campaign settings...';
        case 1:
        return 'What is an ad group anyways?';
        case 2:
        return 'This is the bit I really care about!';
        default:
        return 'Uknown stepIndex';
        }
        }



        class HorizontalLabelPositionBelowStepper extends React.Component {
        state = {
        activeStep: 0,
        };



        handleNext = () => {
        this.setState(state => ({
        activeStep: state.activeStep + 1,
        }));
        };



        handleBack = () => {
        this.setState(state => ({
        activeStep: state.activeStep - 1,
        }));
        };



        handleReset = () => {
        this.setState({
        activeStep: 0,
        });
        };



        render() {
        const { classes } = this.props;
        const steps = getSteps();
        const { activeStep } = this.state;



        return (
        <div className={classes.root}>
        <Stepper activeStep={activeStep} alternativeLabel>
        {steps.map(label => {
        return (
        <Step key={label}>
        <StepLabel>{label}</StepLabel>
        </Step>
        );
        })}
        </Stepper>
        <div>
        {this.state.activeStep === steps.length ? (
        <div>
        <Typography className={classes.instructions}>All steps completed</Typography>
        <Button onClick={this.handleReset}>Reset</Button>
        </div>
        ) : (
        <div>
        <Typography className={classes.instructions}>{getStepContent(activeStep)}</Typography>
        <div>
        <Button
        disabled={activeStep === 0}
        onClick={this.handleBack}
        className={classes.backButton}
        >
        Back
        </Button>
        <Button variant="contained" color="primary" onClick={this.handleNext}>
        {activeStep === steps.length - 1 ? 'Finish' : Next'}
        </Button>
        </div>
        </div>
        )}
        </div>
        </div>
        );


        }
        }



        HorizontalLabelPositionBelowStepper.propTypes = {
        classes: PropTypes.object,
        };



        export default withStyles(styles(HorizontalLabelPositionBelowStepper);









      material-ui create-react-app react-admin






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 23 '18 at 11:42









      Reuben MugambiReuben Mugambi

      1239




      1239
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Incase anyone ever gets stuck on this, I found a nice tutorial on youtube that you can easily follow.






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53446053%2fhow-to-add-material-ui-form-with-steppers-in-react-amin-create-component%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Incase anyone ever gets stuck on this, I found a nice tutorial on youtube that you can easily follow.






            share|improve this answer




























              0














              Incase anyone ever gets stuck on this, I found a nice tutorial on youtube that you can easily follow.






              share|improve this answer


























                0












                0








                0







                Incase anyone ever gets stuck on this, I found a nice tutorial on youtube that you can easily follow.






                share|improve this answer













                Incase anyone ever gets stuck on this, I found a nice tutorial on youtube that you can easily follow.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 1 '18 at 10:05









                Reuben MugambiReuben Mugambi

                1239




                1239
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53446053%2fhow-to-add-material-ui-form-with-steppers-in-react-amin-create-component%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    Xamarin.form Move up view when keyboard appear

                    Post-Redirect-Get with Spring WebFlux and Thymeleaf

                    Anylogic : not able to use stopDelay()