简体   繁体   English

使用表格 ReactJs 在组件中提交模态

[英]Submit Modal in Component with Form ReactJs

I have the following scenario.我有以下情况。 I have a component with a form this form has a component that calls a modal to make another registration, when I submit the modal registration it also does the submit in the main component, has anyone been through this?我有一个带有表单的组件,这个表单有一个调用模态进行另一次注册的组件,当我提交模态注册时,它也在主组件中提交,有人经历过吗?

Sorry my English对不起我的英语

my main component, I use Formik to submit我的主要组件,我使用 Formik 提交

const salvar = (values) => {
if (marca.length === 0) {
  alertError('Marca é obrigatório.');
  return
} else {
  values = {
    nome: values.nome,
    descricao: values.descricao,
    marca: marca.value
  };
  handleSubmit(values, url, AlertSuccess, AlertError, valuesPesonalizados,
    fieldsPesonalizados);
}

Formik...福米克...

<Formik
    initialValues={{
       nome: '',
        descricao: ''
    }}
    validationSchema={SignupSchema}
    onSubmit={salvar}
>

in this case I have a modal component that opens another form在这种情况下,我有一个打开另一个表单的模态组件

this also has the submit with Formik这也有Formik的提交

const salvar = async (values) => {
   handleSubmit(values, url, AlertSuccess, AlertError, valuesPesonalizados,
   fieldsPesonalizados);

} }

<Formik
   initialValues={{
     nome: '',
     descricao: ''
   }}
   validationSchema={SignupSchema}
   onSubmit={salvar}
>

but when submitting in modal it does submit in both components.但是当以模态提交时,它确实在两个组件中都提交。

I've tried to change the submit names but to no avail.我试图更改提交名称,但无济于事。

I have the following scenario.我有以下情况。 I have a component with a form this form has a component that calls a modal to make another registration, when I submit the modal registration it also does the submit in the main component, has anyone been through this?我有一个带有表单的组件,这个表单有一个调用模态进行另一次注册的组件,当我提交模态注册时,它也在主组件中提交,有人经历过吗?

Sorry my English对不起我的英语

my main component, I use Formik to submit我的主要组件,我使用 Formik 提交

const salvar = (values) => {
if (marca.length === 0) {
  alertError('Marca é obrigatório.');
  return
} else {
  values = {
    nome: values.nome,
    descricao: values.descricao,
    marca: marca.value
  };
  handleSubmit(values, url, AlertSuccess, AlertError, valuesPesonalizados,
    fieldsPesonalizados);
}

Formik...福米克...

<Formik
    initialValues={{
       nome: '',
        descricao: ''
    }}
    validationSchema={SignupSchema}
    onSubmit={salvar}
>

in this case I have a modal component that opens another form在这种情况下,我有一个打开另一个表单的模态组件

this also has the submit with Formik这也有Formik的提交

const salvar = async (values) => {
   handleSubmit(values, url, AlertSuccess, AlertError, valuesPesonalizados,
   fieldsPesonalizados);

} }

<Formik
   initialValues={{
     nome: '',
     descricao: ''
   }}
   validationSchema={SignupSchema}
   onSubmit={salvar}
>

but when submitting in modal it does submit in both components.但是当以模态提交时,它确实在两个组件中都提交。

I've tried to change the submit names but to no avail.我试图更改提交名称,但无济于事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM