How to add Material-UI form with Steppers in React-Amin Create Component
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
- How to add components such as to the stepper's function
getStepContent()
How to wrap all input components into a form
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
add a comment |
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
- How to add components such as to the stepper's function
getStepContent()
How to wrap all input components into a form
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
add a comment |
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
- How to add components such as to the stepper's function
getStepContent()
How to wrap all input components into a form
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
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
- How to add components such as to the stepper's function
getStepContent()
How to wrap all input components into a form
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
material-ui create-react-app react-admin
asked Nov 23 '18 at 11:42
Reuben MugambiReuben Mugambi
1239
1239
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Incase anyone ever gets stuck on this, I found a nice tutorial on youtube that you can easily follow.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Incase anyone ever gets stuck on this, I found a nice tutorial on youtube that you can easily follow.
add a comment |
Incase anyone ever gets stuck on this, I found a nice tutorial on youtube that you can easily follow.
add a comment |
Incase anyone ever gets stuck on this, I found a nice tutorial on youtube that you can easily follow.
Incase anyone ever gets stuck on this, I found a nice tutorial on youtube that you can easily follow.
answered Dec 1 '18 at 10:05
Reuben MugambiReuben Mugambi
1239
1239
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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