const CreateProjectComponent = observer(() => {
createProjectForm.onSubmit(
(formInstance: Instance<typeof createProjectForm>) => {
console.log(formInstance.getFormData());
formInstance.setSubmitting(false);
},
);
<Formst formInstance={createProjectForm}>
<form key={'master'} onSubmit={createProjectForm.handleSubmit}>
{createProjectForm.totalMilestone}
<div>
Project name:
{}
<Field name="name" type="text" />
{}
<input
name="name"
value={createProjectForm.name}
onChange={createProjectForm.handleChange}
onBlur={createProjectForm.handleBlur}
/>
</div>
<div>
<ErrorMessage name="name" />
</div>
<div style={{border: '1px solid black'}}>
{}
<Formst formInstance={createProjectForm.team}>
<div key={'second'}>
<div>
Team name:
{}
<Field name="name" type="text" />
</div>
<div>
<ErrorMessage name="name" />
</div>
<div>
Lead name:
<Field name="lead" type="text" />
</div>
<div>
<ErrorMessage name="lead" />
</div>
</div>
</Formst>
</div>
{createProjectForm.milestones.map((milestone, index) => {
return (
<Formst formInstance={milestone} key={index}>
{}
<div key={index}>
<div>
Milestone name:
<input
name="name"
value={milestone.name}
onChange={milestone.handleChange}
onBlur={milestone.handleBlur}
/>
<ErrorMessage name="name" />
</div>
</div>
</Formst>
);
})}
<button type="button" onClick={addMilestone}>
Add new milestone
</button>
<button type="submit">Submit</button>
{createProjectForm.isSubmitting ? (
<h1>submitting</h1>
) : (
<h2>submitted</h2>
)}
{createProjectForm.isValid ? <h1>valid</h1> : <h2>not valid</h2>}
</form>
</Formst>;
});